idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
55,900
|
protected function isFilesystemWritable ( $ path ) { if ( $ this -> getFilesystem ( ) -> isWritable ( ) ) { return true ; } else { return $ this -> setError ( Message :: get ( Message :: STR_FS_NONWRITABLE , $ path ) , Message :: STR_FS_NONWRITABLE ) ; } }
|
Check filesystem writable or not
|
55,901
|
protected function isFilesystemDeletable ( $ path ) { if ( $ this -> getFilesystem ( ) -> isDeletable ( ) ) { return true ; } else { return $ this -> setError ( Message :: get ( Message :: STR_FS_NONDELETABLE , $ path ) , Message :: STR_FS_NONDELETABLE ) ; } }
|
Check filesystem file deletable or not
|
55,902
|
final public function hasclass ( $ classname ) { return ! ! $ this -> hasattr ( 'class' ) ? in_array ( $ classname , explode ( ' ' , $ this -> attrs -> class ) ) : FALSE ; }
|
Permite saber si el elemento posee una clase .
|
55,903
|
final public function parent ( ) { $ parent = NULL ; if ( ! ! isset ( $ this -> dom_element -> parentNode ) ) { if ( $ this -> dom_element -> parentNode -> nodeType == 1 ) { $ parent = new PHPHtmlDomElement ( $ this -> dom_element -> parentNode ) ; } else { $ parent = $ this -> dom_element -> parentNode ; } } return $ parent ; }
|
Permite obtener el elemeno padre si lo posee
|
55,904
|
public function convertToSql ( String $ query , Parameters $ parameterRepository ) : StdClass { $ stdClass = new StdClass ( ) ; $ stdClass -> parameterValues = [ ] ; $ placeholder = '?' ; $ stdClass -> query = '' ; $ match = false ; if ( preg_match_all ( '/\:([^ ,]+)/s' , $ query , $ matched ) ) { $ stdClass -> parameterValues = array_map ( function ( $ value ) use ( $ parameterRepository , $ matched ) { $ value = str_replace ( ',' , '' , $ value ) ; if ( $ parameterRepository -> getParameter ( $ value ) == null ) { throw new InvalidParameterCountException ( 'Number of parameters does not match length of proposed parameters.' , $ matched [ 1 ] , $ parameterRepository ) ; } return $ parameterRepository -> getParameter ( $ value ) ; } , $ matched [ 1 ] ) ; } $ stdClass -> query = str_replace ( $ matched [ 0 ] , '?' , $ query ) ; if ( sizeof ( $ stdClass -> parameterValues ) < 1 ) { $ stdClass -> parameterValues = array_values ( $ parameterRepository -> getAll ( ) ) ; } return $ stdClass ; }
|
Converts a query string with named parameters to marked placeholders and returs an object .
|
55,905
|
public function getSelectedFields ( String $ query ) : Array { $ columns = [ ] ; if ( Type :: getStatementType ( $ query ) == 1 ) { if ( preg_match ( "/(SELECT|select|Select)(.*?)FROM|from|From([^ ]+)/s" , $ query , $ matches ) ) { $ columns = explode ( ',' , $ matches [ 2 ] ) ; $ columns = array_map ( function ( $ field ) { return trim ( ltrim ( $ field ) ) ; } , $ columns ) ; } } return $ columns ; }
|
Returns an array of selected fields in a SELECT statement .
|
55,906
|
public function hasMappableFields ( String $ query ) : Array { $ fields = [ ] ; if ( preg_match ( "/=([^ ]+)?/s" , $ query , $ matches ) ) { $ fields = $ matches ; } return $ fields ; }
|
This method returns an array of fields to map in a query .
|
55,907
|
public function isChecked ( ) { if ( null == $ this -> checked ) { $ this -> checked = StaticFilter :: filter ( Boolean :: class , $ this -> getValue ( ) ) ; } return $ this -> checked ; }
|
Check whenever the checkbox state is checked
|
55,908
|
public function getAttributes ( ) { $ attributes = parent :: getAttributes ( ) ; if ( $ this -> isChecked ( ) ) { $ attributes -> set ( 'checked' , null ) ; } return $ attributes ; }
|
Get the attributes map collection
|
55,909
|
public function addDetectedLanguage ( $ language ) { if ( ! in_array ( $ language , $ this -> detectedLanguages ) ) { $ this -> detectedLanguages [ ] = $ language ; } return $ this ; }
|
Add detected languages
|
55,910
|
public function getVoteLanguages ( $ mode = null ) { arsort ( $ this -> votes , SORT_NUMERIC ) ; if ( self :: VOTED_HIGH === $ mode ) { if ( ! count ( $ this -> votes ) ) { return $ this -> votes ; } $ languages = array ( ) ; list ( $ language , $ highVote ) = each ( $ this -> votes ) ; $ languages [ ] = $ language ; while ( $ item = each ( $ this -> votes ) ) { list ( $ language , $ votes ) = $ item ; if ( $ highVote === $ votes ) { $ languages [ ] = $ language ; } else { break ; } } return $ languages ; } return $ this -> votes ; }
|
Get vote languages
|
55,911
|
public function getPrimaryLanguage ( array $ priorityLanguages = array ( ) ) { $ votedLanguages = $ this -> getVoteLanguages ( self :: VOTED_HIGH ) ; if ( ! count ( $ votedLanguages ) ) { $ votedLanguages = $ this -> getVoteLanguages ( ) ; if ( ! count ( $ votedLanguages ) ) { return null ; } } if ( ! count ( $ priorityLanguages ) ) { return array_shift ( $ votedLanguages ) ; } if ( count ( $ priorityLanguages ) == 1 ) { return $ priorityLanguages [ 0 ] ; } foreach ( $ priorityLanguages as $ priorityLanguage ) { if ( in_array ( $ priorityLanguage , $ votedLanguages ) ) { return $ priorityLanguage ; } } return array_shift ( $ priorityLanguages ) ; }
|
Get primary language
|
55,912
|
protected function getArg ( $ name ) { if ( isset ( $ this -> request [ 'post' ] [ $ name ] ) ) { return $ this -> request [ 'post' ] [ $ name ] ; } else { return $ this -> getURLArg ( $ name ) ; } }
|
Return an argument first from POST or from GET if POST fails
|
55,913
|
public function Exception ( $ exception ) { $ auditlog = Sonic :: getResource ( 'auditlog' ) ; if ( $ auditlog instanceof Resource \ Audit \ Log ) { $ auditlog :: _Log ( get_called_class ( ) . '\\' . $ this -> action , 7 , $ this -> request , array ( 'file' => $ exception -> getFile ( ) , 'line' => $ exception -> getLine ( ) , 'message' => $ exception -> getMessage ( ) ) ) ; } echo 'Uncaught exception `' . $ exception -> getMessage ( ) . '` in ' . $ exception -> getFile ( ) . ' on line ' . $ exception -> getLine ( ) ; }
|
Deal with an exception
|
55,914
|
public function authenticate ( Request $ request ) { return $ request -> get ( 'username' ) === $ this -> username && password_verify ( $ request -> get ( 'password' ) , $ this -> password ) ; }
|
Returns true if the given Request meets authentication requirements
|
55,915
|
public function relation ( string $ table , string $ bindKey , string $ srcKey = 'id' , Closure $ userExe = null ) : Builder { $ this -> rsRender ( $ table , $ bindKey , $ srcKey , null , $ userExe ) ; return $ this ; }
|
similar with relations but merge single - data in source
|
55,916
|
public function relations ( string $ table , string $ bindKey , string $ listKey , string $ srcKey = 'id' , Closure $ userExe = null ) : Builder { $ this -> rsRender ( $ table , $ bindKey , $ srcKey , $ listKey , $ userExe ) ; return $ this ; }
|
similar with relation but attach listed - data in source
|
55,917
|
public function get ( $ key , $ default = null ) { if ( Arrays :: exists ( $ key , $ this -> attributes ) ) { return $ this -> attributes [ $ key ] ; } return value ( $ default ) ; }
|
Get an attribute from the container .
|
55,918
|
public function setStateNotVoid ( ) { if ( $ this -> state === State :: VOID ) { $ this -> state = $ this -> hasSavedProperties ( ) ? State :: SAVED : State :: PENDING ; } return $ this ; }
|
if the model has id it becomes SAVED otherwise - pending
|
55,919
|
public function getRelationships ( $ modelName ) { if ( $ this -> models -> has ( $ modelName ) && $ this -> models -> get ( $ modelName ) -> has ( 'relationships' ) ) { return $ this -> models -> get ( $ modelName ) -> get ( 'relationships' ) ; } return new Map ( ) ; }
|
Returns the relationships for a model
|
55,920
|
public function getNormalizer ( $ modelName ) { if ( $ this -> models -> has ( $ modelName ) && $ this -> models -> get ( $ modelName ) -> has ( 'normalizer' ) ) { return $ this -> models -> get ( $ modelName ) -> get ( 'normalizer' ) ; } return new Map ( ) ; }
|
Returns normalizer for a model
|
55,921
|
public function getIncludes ( $ modelName ) { if ( $ this -> models -> has ( $ modelName ) && $ this -> models -> get ( $ modelName ) -> has ( 'includes' ) ) { return $ this -> models -> get ( $ modelName ) -> get ( 'includes' ) ; } return new ArrayList ( ) ; }
|
Returns additional includes for a given model
|
55,922
|
public function isValid ( $ headersOnly = false ) { $ accessToken = $ this -> determineAccessToken ( $ headersOnly ) ; $ result = $ this -> storages [ 'session' ] -> validateAccessToken ( $ accessToken ) ; if ( ! $ result ) { throw new InvalidAccessTokenException ( 'Access token is not valid' ) ; } $ this -> accessToken = $ accessToken ; $ this -> sessionId = $ result [ 'session_id' ] ; $ this -> clientId = $ result [ 'client_id' ] ; $ this -> ownerType = $ result [ 'owner_type' ] ; $ this -> ownerId = $ result [ 'owner_id' ] ; $ sessionScopes = $ this -> storages [ 'session' ] -> getScopes ( $ this -> accessToken ) ; foreach ( $ sessionScopes as $ scope ) { $ this -> sessionScopeIds [ ] = $ scope [ 'id' ] ; $ this -> sessionScopes [ ] = $ scope [ 'scope' ] ; } return true ; }
|
Checks if the access token is valid or not .
|
55,923
|
public function determineAccessToken ( $ headersOnly = false ) { $ header = $ this -> getRequest ( ) -> header ( 'Authorization' ) ; $ accessToken = '' ; if ( strpos ( $ header , 'Bearer' ) !== false ) { if ( strpos ( $ header , ',' ) !== false ) { $ headerPart = explode ( ',' , $ header ) ; $ accessToken = trim ( preg_replace ( '/^(?:\s+)?Bearer\s/' , '' , $ headerPart [ 0 ] ) ) ; } else { $ accessToken = trim ( preg_replace ( '/^(?:\s+)?Bearer\s/' , '' , $ header ) ) ; } $ accessToken = ( $ accessToken === 'Bearer' or $ accessToken === 'Basic' ) ? '' : $ accessToken ; } if ( ! empty ( $ accessToken ) ) { return $ accessToken ; } elseif ( $ headersOnly === false ) { $ input = RequestFacade :: all ( ) ; if ( array_key_exists ( $ this -> tokenKey , $ input ) ) { $ accessToken = $ input [ $ this -> tokenKey ] ; } unset ( $ input ) ; } if ( empty ( $ accessToken ) ) { throw new InvalidAccessTokenException ( 'Access token is missing' ) ; } return $ accessToken ; }
|
Reads in the access token from the headers .
|
55,924
|
public function push ( RenderingContext $ context ) { if ( $ this -> getLevel ( ) == self :: COMPONENT ) { throw new \ BadMethodCallException ( 'Cannot push another context : stack is full. Resolve or flush current one first' ) ; } array_unshift ( $ this -> stack , $ context ) ; return $ this ; }
|
Push given context over the stack making it the current one .
|
55,925
|
public function setSMTPStream ( $ smtp = FALSE ) { if ( is_array ( $ smtp ) ) { $ this -> smtp = $ smtp ; } else { $ this -> smtp = array ( 'server' => defined ( 'EMAIL_SERVER' ) ? EMAIL_SERVER : NULL , 'port' => defined ( 'EMAIL_PORT' ) ? EMAIL_PORT : NULL , 'domain' => defined ( 'EMAIL_DOMAIN' ) ? EMAIL_DOMAIN : NULL , 'username' => defined ( 'EMAIL_USERNAME' ) ? EMAIL_USERNAME : NULL , 'password' => defined ( 'EMAIL_PASSWORD' ) ? EMAIL_PASSWORD : NULL ) ; } $ this -> _useStream = TRUE ; $ this -> _nl = "\r\n" ; }
|
Use SMTP stream to send mail
|
55,926
|
public function setPHPMail ( ) { $ this -> _useStream = FALSE ; if ( isset ( $ _SERVER [ 'QMAIL' ] ) ) { $ this -> _nl = "\n" ; } else { $ this -> _nl = "\r\n" ; } }
|
Use PHP to send mail
|
55,927
|
private function addHeader ( $ header , $ unique = FALSE ) { if ( is_array ( $ header ) ) { $ this -> _headers = array_merge ( $ this -> _headers , $ header ) ; } else { if ( $ unique ) { $ headerArray = explode ( ':' , $ header ) ; $ headerKey = $ headerArray [ 0 ] ; foreach ( $ this -> _headers as $ key => $ val ) { if ( stripos ( $ val , $ headerKey ) === 0 ) { unset ( $ this -> _headers [ $ key ] ) ; } } } $ this -> _headers [ ] = $ header ; } }
|
Add Email Header
|
55,928
|
public function addHTML ( $ html , $ plain = FALSE ) { $ this -> _htmlSet = TRUE ; if ( $ plain ) { $ this -> addPlain ( $ plain ) ; } $ this -> _html [ ] = $ html ; }
|
Add HTML to Email Message
|
55,929
|
public function addImage ( $ filePath , $ fileName = NULL ) { if ( ! file_exists ( $ filePath ) ) { new \ Sonic \ Message ( 'error' , $ filePath . ' doesnt exist!' ) ; return FALSE ; } if ( ! $ imgData = getimagesize ( $ filePath ) ) { new \ Sonic \ Message ( 'error' , 'Cannot get MIME type!' ) ; return FALSE ; } if ( ! in_array ( $ imgData [ 2 ] , $ this -> _imagesAllowed ) ) { $ allowedTypes = NULL ; $ x = 0 ; foreach ( $ this -> _imagesAllowed as $ type ) { $ x ++ ; $ allowedTypes .= image_type_to_extension ( $ type ) ; if ( $ x < count ( $ this -> _imagesAllowed ) ) { $ allowedTypes .= ', ' ; } } new \ Sonic \ Message ( 'error' , 'Invalid image type: image must be ' . $ allowedTypes ) ; return FALSE ; } if ( ! $ fileData = @ file_get_contents ( $ filePath ) ) { new \ Sonic \ Message ( 'error' , 'Cannot get image data!' ) ; return FALSE ; } $ this -> _imagesSet = TRUE ; $ this -> _images [ ] = array ( 'name' => $ fileName , 'data' => $ fileData , 'type' => image_type_to_mime_type ( $ imgData [ 2 ] ) , 'cid' => md5 ( uniqid ( time ( ) ) ) ) ; return TRUE ; }
|
Add Image to Email Message
|
55,930
|
public function addAttachment ( $ filePath = FALSE , $ fileName = NULL , $ fileData = FALSE , $ mimeType = 'text/plain' ) { if ( $ filePath !== FALSE ) { if ( ! file_exists ( $ filePath ) ) { new \ Sonic \ Message ( 'error' , $ filePath . ' doesnt exist!' ) ; return FALSE ; } $ objFinfo = new finfo ; if ( ! $ mimeType = $ objFinfo -> file ( $ filePath , FILEINFO_MIME ) ) { new \ Sonic \ Message ( 'error' , 'Cannot get MIME type!' ) ; return FALSE ; } if ( ! $ fileData = @ file_get_contents ( $ filePath ) ) { new \ Sonic \ Message ( 'error' , 'Cannot get attachment data!' ) ; return FALSE ; } } else if ( ! $ fileData || ! $ fileName ) { new \ Sonic \ Message ( 'error' , 'Invalid Attachment!' ) ; return FALSE ; } $ this -> _attachmentsSet = TRUE ; $ this -> _attachments [ ] = array ( 'name' => $ fileName , 'data' => $ fileData , 'type' => $ mimeType ) ; return TRUE ; }
|
Add Attachment to Email Message
|
55,931
|
public function setTemplate ( $ file ) { $ tpl = \ Sonic \ Sonic :: getResource ( 'tpl' ) ; if ( $ tpl instanceof \ Smarty && ! is_readable ( $ file ) ) { $ file = $ tpl -> getTemplateDir ( 0 ) . $ file ; } if ( is_readable ( $ file ) ) { $ this -> _tpl = $ file ; } }
|
Set the message template file to user
|
55,932
|
private function constructImage ( $ image , $ boundary ) { $ output = NULL ; $ output .= '--' . $ boundary . $ this -> _nl ; $ output .= 'Content-Type: ' . $ image [ 'type' ] ; if ( $ image [ 'name' ] ) { $ output .= '; name="' . $ image [ 'name' ] . '"' ; } $ output .= $ this -> _nl ; $ output .= 'Content-Transfer-Encoding: base64' . $ this -> _nl ; $ output .= 'Content-ID: <' . $ image [ 'cid' ] . '>' . str_repeat ( $ this -> _nl , 2 ) ; $ output .= chunk_split ( base64_encode ( $ image [ 'data' ] ) , 70 ) . $ this -> _nl ; return $ output ; }
|
Construct the specified image and add it to the message
|
55,933
|
private function constructAttachment ( $ attachment , $ boundary ) { $ output = NULL ; $ output .= '--' . $ boundary . $ this -> _nl ; $ output .= 'Content-Type: ' . $ attachment [ 'type' ] ; if ( $ attachment [ 'name' ] ) { $ output .= '; name="' . $ attachment [ 'name' ] . '"' ; } $ output .= $ this -> _nl ; $ output .= 'Content-Transfer-Encoding: base64' . $ this -> _nl ; if ( $ attachment [ 'type' ] == 'text/plain' ) { $ output .= $ this -> _nl ; } else { $ output .= 'Content-Disposition: attachment; filename="' . $ attachment [ 'name' ] . '"' . str_repeat ( $ this -> _nl , 2 ) ; } $ output .= chunk_split ( base64_encode ( $ attachment [ 'data' ] ) , 70 ) . $ this -> _nl ; return $ output ; }
|
Construct the specified attachment and add it to the message
|
55,934
|
private function constructBody ( ) { $ body = NULL ; foreach ( $ this -> _body as $ bodyBlock ) { $ body .= $ bodyBlock ; } return $ this -> addAttachment ( FALSE , NULL , $ body ) ; }
|
Construct the message body
|
55,935
|
private function constructHeaders ( ) { $ headers = NULL ; foreach ( $ this -> _headers as $ header ) { $ headers .= $ header . $ this -> _nl ; } return $ headers ; }
|
Construct the message headers
|
55,936
|
public function Build ( ) { $ boundary = '=====' . md5 ( uniqid ( time ( ) ) ) ; $ this -> _headers = array ( ) ; $ this -> addHeader ( 'MIME-version: 1.0' ) ; $ this -> addHeader ( 'Content-Type: Multipart/alternative;' . $ this -> _nl . chr ( 9 ) . 'boundary="' . $ boundary . '"' ) ; $ this -> _message = NULL ; if ( $ this -> _tpl ) { $ this -> addHTML ( @ file_get_contents ( $ this -> _tpl ) ) ; } if ( $ this -> _htmlSet || $ this -> _plain ) { $ this -> _message .= $ this -> constructHTML ( $ boundary ) ; } if ( $ this -> _bodySet ) { if ( ! $ this -> constructBody ( ) ) { new \ Sonic \ Message ( 'error' , 'Cannot add message body!' ) ; return FALSE ; } } if ( $ this -> _attachmentsSet ) { foreach ( $ this -> _attachments as $ attachment ) { $ this -> _message .= $ this -> constructAttachment ( $ attachment , $ boundary ) ; } } $ this -> _message .= '--' . $ boundary . '--' . $ this -> _nl ; return TRUE ; }
|
Construct the email message
|
55,937
|
public function Send ( $ from , $ subject = FALSE , $ headers = FALSE ) { if ( preg_match ( '/(.*?)<(.*?)>/' , $ from , $ fromArray ) ) { $ this -> _fromName = trim ( $ fromArray [ 1 ] ) ; $ this -> _fromAddress = $ fromArray [ 2 ] ; try { Parser :: _Validate ( 'From name' , array ( 'type' => \ Sonic \ Model :: TYPE_STRING , 'charset' => 'alpha' , 'min' => 1 , 'max' => 255 ) , $ this -> _fromName ) ; Parser :: _validateEmail ( $ this -> _fromAddress ) ; } catch ( Parser \ Exception $ e ) { new \ Sonic \ Message ( 'error' , $ e -> getMessage ( ) ) ; return FALSE ; } } else { new \ Sonic \ Message ( 'error' , 'Invalid from format, must be Name<user@domain.com>: ' . $ from ) ; return FALSE ; } if ( $ subject !== FALSE ) { $ this -> setSubject ( $ subject ) ; } if ( ! $ this -> _subject ) { new \ Sonic \ Message ( 'error' , 'No message subject!' ) ; return FALSE ; } if ( ! $ this -> Build ( ) ) { new \ Sonic \ Message ( 'error' , 'Cannot build the message!' ) ; return FALSE ; } if ( $ headers !== FALSE ) { $ this -> addHeader ( $ headers ) ; } if ( $ this -> _subject ) { $ this -> addHeader ( 'Subject: ' . $ this -> _subject , TRUE ) ; } $ this -> addHeader ( 'From: ' . $ this -> _fromName . '<' . $ this -> _fromAddress . '>' , TRUE ) ; $ this -> addHeader ( 'Date: ' . date ( 'r' ) , TRUE ) ; if ( $ this -> _useStream ) { return $ this -> sendUsingStream ( ) ; } else { return $ this -> sendUsingPHP ( ) ; } }
|
Construct message if not done already and send email . Attribute to and from addresses will replace any to or from headers
|
55,938
|
private function sendUsingPHP ( ) { $ headers = $ this -> constructHeaders ( ) ; $ tpl = \ Sonic \ Sonic :: getResource ( 'tpl' ) ; $ smarty = $ tpl instanceof \ Smarty ; if ( $ smarty ) { $ smartyPrevCache = $ tpl -> caching ; $ tpl -> setCaching ( FALSE ) ; } foreach ( $ this -> _recipients as $ recipient ) { try { Parser :: _validateEmail ( $ recipient [ 'email' ] ) ; if ( isset ( $ recipient [ 'name' ] ) ) { $ recipientTo = $ recipient [ 'name' ] . '<' . $ recipient [ 'email' ] . '>' ; } else { $ recipientTo = $ recipient [ 'email' ] ; } $ emailHeaders = $ headers . 'To: ' . $ recipientTo . $ this -> _nl ; if ( $ smarty ) { $ tpl -> clearAllAssign ( ) ; $ tpl -> assign ( 'recipient' , $ recipient ) ; $ emailMessage = $ tpl -> fetch ( 'string:' . $ this -> _message ) ; } else { $ emailMessage = $ this -> _message ; } if ( ! mail ( $ recipientTo , $ this -> _subject , $ emailMessage , $ emailHeaders ) ) { new \ Sonic \ Message ( 'error' , 'Cannot send message to: ' . $ recipient [ 'email' ] ) ; return FALSE ; } if ( is_callable ( $ this -> _callbackMethod ) ) { call_user_func ( $ this -> _callbackMethod , $ this -> _subject , $ recipientTo , $ this -> _fromAddress , $ emailMessage ) ; } if ( $ this -> logFlag ) { $ this -> Log ( $ recipient [ 'email' ] , $ emailHeaders , $ emailMessage , 'phpmail' ) ; } } catch ( Parser \ Exception $ e ) { new \ Sonic \ Message ( 'error' , 'Invalid recipient email address: ' . $ recipient [ 'email' ] ) ; continue ; } } if ( $ smarty ) { $ tpl -> caching = $ smartyPrevCache ; } return TRUE ; }
|
Send email to recipients using PHP mail
|
55,939
|
protected function Log ( $ recipient , $ headers , $ email , $ method ) { $ filename = date ( 'Y-m-d_H-i-s' ) . '_' . $ method . '_' . $ recipient . '.txt' ; @ file_put_contents ( EMAIL_LOG_PATH . $ filename , $ headers . $ email ) ; }
|
Log sent message
|
55,940
|
protected function registerConfigs ( Application $ app ) { $ base = $ app [ 'path.base' ] ; if ( file_exists ( "$base/.env" ) ) { $ dotenv = \ Dotenv :: load ( $ base ) ; } $ preloadedVars = [ 'env.DEBUG' => $ app [ 'debug' ] , 'env.AUTO_REBUILD' => $ app [ 'auto_rebuild' ] , 'env.DOMAIN' => isset ( $ _SERVER [ 'SERVER_NAME' ] ) ? $ _SERVER [ 'SERVER_NAME' ] : 'skimpy.dev' , 'path.base' => $ base , ] ; $ envVars = $ _ENV ; foreach ( $ envVars as $ k => $ v ) { $ preloadedVars [ "env.$k" ] = $ v ; } $ app -> register ( new \ Igorw \ Silex \ ConfigServiceProvider ( "$base/config/site.php" ) ) ; }
|
Register the config provider and load the default configs
|
55,941
|
protected function registerTwig ( Application $ app , $ base ) { $ app -> register ( new \ Silex \ Provider \ TwigServiceProvider , [ 'twig.path' => $ base . '/templates' , 'twig.options' => [ 'debug' => $ app [ 'debug' ] , 'cache' => $ base . '/cache/templates' , ] , ] ) ; $ this -> addDateDefaultFormatToTwig ( $ app ) ; }
|
Register the TwigServiceProvider
|
55,942
|
protected function addDateDefaultFormatToTwig ( Application $ app ) { $ app [ 'twig' ] = $ app -> share ( $ app -> extend ( 'twig' , function ( \ Twig_Environment $ twig , Application $ app ) { $ defaultDateFormat = new \ Twig_SimpleFilter ( 'date_default_format' , function ( \ DateTime $ date ) use ( $ app ) { $ format = isset ( $ app [ 'site.date_format' ] ) ? $ app [ 'site.date_format' ] : 'Y-m-d H:i:s' ; return $ date -> format ( $ format ) ; } ) ; $ twig -> addFilter ( $ defaultDateFormat ) ; return $ twig ; } ) ) ; }
|
Twig date_default_format filter
|
55,943
|
public static function getMimeType ( $ file ) { $ finfo = finfo_open ( FILEINFO_MIME_TYPE ) ; $ type = finfo_file ( $ finfo , $ file ) ; finfo_close ( $ finfo ) ; return $ type ; }
|
get the MIME Type of a file .
|
55,944
|
public static function getMimeTypeFromFilename ( $ fileName ) { $ ext = strtolower ( pathinfo ( $ fileName , PATHINFO_EXTENSION ) ) ; if ( array_key_exists ( $ ext , self :: $ customMimeTypes ) ) { return self :: $ customMimeTypes [ $ ext ] ; } else if ( array_key_exists ( $ ext , self :: $ mimeTypes ) ) { return self :: $ mimeTypes [ $ ext ] ; } return 'application/octet-stream' ; }
|
get the MIME Type of a file only with its name .
|
55,945
|
protected function _getListInstallerCommandsFull ( ) { $ result = [ CAKE_INSTALLER_SHELL_INSTALLER_TASK_SETUILANG => __d ( 'cake_installer' , 'Setting application UI language' ) , CAKE_INSTALLER_SHELL_INSTALLER_TASK_CHECK => __d ( 'cake_installer' , 'Checking PHP environment' ) , CAKE_INSTALLER_SHELL_INSTALLER_TASK_SETDIRPERMISS => __d ( 'cake_installer' , 'Setting file system permissions on the temporary directory' ) , CAKE_INSTALLER_SHELL_INSTALLER_TASK_SETSECURKEY => __d ( 'cake_installer' , 'Setting security key' ) , CAKE_INSTALLER_SHELL_INSTALLER_TASK_SETTIMEZONE => __d ( 'cake_installer' , 'Setting timezone' ) , CAKE_INSTALLER_SHELL_INSTALLER_TASK_SETBASEURL => __d ( 'cake_installer' , 'Setting base URL' ) , CAKE_INSTALLER_SHELL_INSTALLER_TASK_CONNECT_DB => __d ( 'cake_installer' , 'Checking connect to database' ) , CAKE_INSTALLER_SHELL_INSTALLER_TASK_CONFIG_DB => __d ( 'cake_installer' , 'Configure database connections' ) , CAKE_INSTALLER_SHELL_INSTALLER_TASK_CREATE_DB => __d ( 'cake_installer' , 'Creation database and initialization data' ) , CAKE_INSTALLER_SHELL_INSTALLER_TASK_CREATE_SYMLINKS => __d ( 'cake_installer' , 'Creation symbolic links to files' ) , CAKE_INSTALLER_SHELL_INSTALLER_TASK_CREATE_CRONJOBS => __d ( 'cake_installer' , 'Creation cron jobs' ) , CAKE_INSTALLER_SHELL_INSTALLER_TASK_INSTALL => __d ( 'cake_installer' , 'Install this application' ) , ] ; return $ result ; }
|
Return full list of installer commands
|
55,946
|
public function getListInstallerCommands ( $ returnList = true ) { $ commandsList = $ this -> _getListInstallerCommandsFull ( ) ; $ installerCommands = $ this -> _getConfigValueArray ( 'installerCommands' ) ; $ result = array_intersect_key ( $ commandsList , array_flip ( $ installerCommands ) ) ; if ( $ returnList ) { $ result = array_keys ( $ result ) ; } return $ result ; }
|
Return list of installer commands
|
55,947
|
public function registerJs ( ) { if ( Yii :: $ app -> request -> isAjax ) { return ; } $ js = <<<'JS' $(document.body).on("click", "a.toggle-column", function(e) { e.preventDefault(); $.post($(this).attr("href"), function(data) { var pjaxId = $(e.target).closest("[data-pjax-container]").attr("id"); $.pjax.reload({container:"#" + pjaxId}); }); return false;});JS ; $ this -> grid -> view -> registerJs ( $ js , View :: POS_READY , 'pheme-toggle-column' ) ; }
|
Registers the ajax JS
|
55,948
|
private function buildConnection ( ) { $ connection = stream_socket_client ( "tcp://{$this->host}:{$this->port}" , $ errno , $ message ) ; $ success = fread ( $ connection , 26 ) ; if ( false === $ connection || false === $ success ) { throw new \ UnexpectedValueException ( "Failed to connect: $message" ) ; } return $ connection ; }
|
Builds and tests the connection to the Database
|
55,949
|
public function getAction ( $ item ) { $ options = [ 'query' => [ 'item' => $ this -> getItemId ( $ item ) , 'processor' => $ this -> getId ( ) , ] , ] ; if ( $ this -> isLinkDialog ( ) ) { $ options [ 'attributes' ] [ 'class' ] [ ] = 'use-ajax' ; $ options [ 'attributes' ] [ 'class' ] [ ] = 'minidialog' ; $ options [ 'query' ] [ 'minidialog' ] = 1 ; $ options [ 'query' ] += drupal_get_destination ( ) ; } return new Action ( $ this -> getLinkTitle ( ) , 'admin/calista/action-process' , $ options , $ this -> getLinkIcon ( ) , $ this -> getLinkPriority ( ) , $ this -> isLinkPrimary ( ) , true , false , $ this -> getLinkGroup ( ) ) ; }
|
Get ready to use action
|
55,950
|
public static function async ( $ executable , $ arguments = [ ] , $ output_stream = '/dev/null' ) { exec ( $ executable . ( $ arguments ? ' ' . join ( ' ' , $ arguments ) : '' ) . '>' . $ output_stream . ' 2>&1 &' ) ; }
|
Execute asynchronously using exec
|
55,951
|
public static function file ( $ executable , $ arguments = [ ] , & $ output = false ) { $ return_var = 0 ; exec ( $ executable . ( $ arguments ? ' ' . join ( ' ' , $ arguments ) : '' ) , $ output , $ return_var ) ; return $ return_var ; }
|
Execute using exec
|
55,952
|
public function hasWarningMessages ( ) { $ namespace = $ this -> getNamespace ( ) ; $ this -> setNamespace ( self :: NAMESPACE_WARNING ) ; $ hasMessages = $ this -> hasMessages ( ) ; $ this -> setNamespace ( $ namespace ) ; return $ hasMessages ; }
|
Whether warning namespace has messages
|
55,953
|
public function addWarningMessage ( $ message ) { $ namespace = $ this -> getNamespace ( ) ; $ this -> setNamespace ( self :: NAMESPACE_WARNING ) ; $ this -> addMessage ( $ message ) ; $ this -> setNamespace ( $ namespace ) ; return $ this ; }
|
Add a message with warning type
|
55,954
|
public function getWarningMessages ( ) { $ namespace = $ this -> getNamespace ( ) ; $ this -> setNamespace ( self :: NAMESPACE_WARNING ) ; $ messages = $ this -> getMessages ( ) ; $ this -> setNamespace ( $ namespace ) ; return $ messages ; }
|
Get messages from warning namespace
|
55,955
|
public function menuLink ( $ title , $ url = null , array $ options = [ ] ) { if ( ! empty ( $ url [ 'controller' ] ) && strtolower ( $ this -> request -> getParam ( 'controller' ) ) == strtolower ( $ url [ 'controller' ] ) && ! empty ( $ url [ 'action' ] ) && ( strtolower ( $ this -> request -> getParam ( 'action' ) ) == strtolower ( $ url [ 'action' ] ) || ( strtolower ( $ url [ 'controller' ] ) == 'pages' && strtolower ( $ this -> request -> getParam ( 'action' ) ) == 'display' && strtolower ( $ this -> request -> getParam ( 'pass' ) [ 0 ] ) == strtolower ( $ url [ 'action' ] ) ) ) ) { $ options [ 'class' ] = 'active' ; } return parent :: link ( $ title , $ url , $ options ) ; }
|
Adds an active css class to links which pointing to the current url
|
55,956
|
private function cleanup ( $ bind ) { if ( ! is_array ( $ bind ) ) { if ( ! empty ( $ bind ) ) $ bind = array ( $ bind ) ; else $ bind = array ( ) ; } return $ bind ; }
|
Remove all data from bind array
|
55,957
|
private function debug ( ) { if ( ! empty ( $ this -> _errorCallbackFunction ) ) { $ error = array ( "Error" => $ this -> _error ) ; if ( ! empty ( $ this -> _sql ) ) $ error [ "SQL Statement" ] = $ this -> _sql ; if ( ! empty ( $ this -> _bind ) ) $ error [ "Bind Parameters" ] = trim ( print_r ( $ this -> _bind , true ) ) ; $ backtrace = debug_backtrace ( ) ; if ( ! empty ( $ backtrace ) ) { foreach ( $ backtrace as $ info ) { if ( isset ( $ info [ "file" ] ) && $ info [ "file" ] != __FILE__ ) $ error [ "Backtrace_Line_" . $ info [ "line" ] ] = $ info [ "file" ] . " at line " . $ info [ "line" ] ; } } $ msg = "" ; $ msg .= "SQL Error\n" . str_repeat ( "-" , 50 ) ; foreach ( $ error as $ key => $ val ) { $ msg .= "\n\n$key:\n$val" ; } $ this -> logger -> error ( $ msg ) ; } }
|
Used for query debugging purpose
|
55,958
|
public function setErrorCallbackFunction ( $ errorCallbackFunction , $ errorMsgFormat = "html" ) { if ( in_array ( strtolower ( $ errorCallbackFunction ) , array ( "echo" , "print" ) ) ) $ errorCallbackFunction = "print_r" ; if ( function_exists ( $ errorCallbackFunction ) ) { $ this -> _errorCallbackFunction = $ errorCallbackFunction ; if ( ! in_array ( strtolower ( $ errorMsgFormat ) , array ( "html" , "text" ) ) ) $ errorMsgFormat = "html" ; $ this -> _errorMsgFormat = $ errorMsgFormat ; } }
|
Sets the error callback function
|
55,959
|
public function handle ( ) { if ( ! ( $ this -> exception instanceof \ ErrorException ) ) { $ this -> quit = true ; } else { switch ( $ this -> exception -> getSeverity ( ) ) { case E_ERROR : case E_CORE_ERROR : case E_USER_ERROR : $ this -> quit = true ; } } if ( $ this -> exception instanceof \ ErrorException ) { $ error_type = \ Skeleton \ Error \ Util \ Misc :: translate_error_code ( $ this -> exception -> getSeverity ( ) ) ; } else { $ error_type = 'Exception' ; } $ output = "\n" ; $ output .= 'Error: ' . $ this -> exception -> getMessage ( ) . "\n" ; $ output .= 'Type: ' . $ error_type . "\n" ; $ output .= 'File: ' . $ this -> exception -> getFile ( ) . "\n" ; $ output .= 'Line: ' . $ this -> exception -> getLine ( ) . "\n" ; $ output .= 'Time: ' . date ( 'Y-m-d H:i:s' ) . "\n" ; if ( ! ( $ this -> exception instanceof \ ErrorException ) ) { ob_start ( ) ; debug_print_backtrace ( ) ; $ backtrace = ob_get_clean ( ) ; $ output .= "\n" ; $ output .= $ backtrace . "\n" ; } return $ output ; }
|
Handle an error with the most basic handler on the CLI
|
55,960
|
public function find ( ) { $ config = $ this -> container [ 'config' ] -> get ( 'rinvex.modulable' ) ; foreach ( $ config [ 'paths' ] as $ path ) { foreach ( $ this -> container [ 'files' ] -> glob ( $ path . '/*/*/composer.json' ) as $ module ) { if ( mb_strpos ( $ module , 'cortex/foundation' ) === false && ( $ json = json_decode ( $ this -> container [ 'files' ] -> get ( $ module ) , true ) ) && in_array ( $ json [ 'type' ] , $ config [ 'types' ] ) && in_array ( $ json [ 'name' ] , $ config [ 'enabled' ] ) ) { $ json [ 'path' ] = dirname ( realpath ( $ module ) ) ; $ json [ 'namespace' ] = array_first ( array_keys ( array_pull ( $ json , 'autoload.psr-4' ) ) ) ; $ json [ 'aggregator' ] = $ this -> container [ 'files' ] -> exists ( $ json [ 'path' ] . '/src/Providers/AggregateServiceProvider.php' ) ? $ json [ 'namespace' ] . 'Providers\AggregateServiceProvider' : null ; $ this -> modules [ $ json [ 'name' ] ] = new Module ( $ this -> container , $ json ) ; } } } return $ this ; }
|
Find elligable modules .
|
55,961
|
public function assertIsArrayAndNotEmpty ( $ value , $ message = '%s must not be an empty Array' , $ exception = 'Asserts' ) { if ( isset ( $ value ) === false || is_array ( $ value ) === false || ( is_array ( $ value ) && count ( $ value ) <= 0 ) ) { $ this -> throwException ( $ exception , $ message , $ value ) ; } }
|
Verifies that the specified condition is not empty array . The assertion fails if the condition is not array or it s an empty array .
|
55,962
|
public function isClosed ( ) : bool { foreach ( $ this -> geometries as $ geometry ) { if ( ! $ geometry -> isClosed ( ) ) { return false ; } } return true ; }
|
Indicates whether the MultiCurve is closed .
|
55,963
|
public function modalbox ( String $ id , Array $ data = [ ] ) { $ data = [ 'modalId' => $ id , 'modalHeader' => $ this -> settings [ 'attr' ] [ 'modal-header' ] ?? NULL , 'modalBody' => $ this -> settings [ 'attr' ] [ 'modal-body' ] ?? NULL , 'modalFooter' => $ this -> settings [ 'attr' ] [ 'modal-footer' ] ?? NULL , 'modalSize' => $ this -> settings [ 'attr' ] [ 'modal-size' ] ?? NULL , 'modalDismissButton' => $ this -> settings [ 'attr' ] [ 'modal-dismiss-button' ] ?? NULL ] ; $ this -> settings [ 'attr' ] = [ ] ; return $ this -> getModalResource ( 'standart' , $ data ) ; }
|
Generate modal box
|
55,964
|
public function serializer ( String $ url , $ selector = '.modal-body' , $ datatype = 'standart' ) { $ selector = is_string ( $ selector ) ? ( $ this -> settings [ 'attr' ] [ 'data-target' ] ?? NULL ) . Base :: prefix ( $ selector , ' ' ) : $ selector ; return $ this -> trigger ( 'click' , $ url , $ selector , $ datatype , 'serializer' ) ; }
|
Serilize form into controller
|
55,965
|
protected function stringOrCallback ( $ content ) { if ( is_scalar ( $ content ) ) { return $ content ; } elseif ( is_callable ( $ content ) ) { return Buffering \ Callback :: do ( $ content ) ; } throw new Exception \ InvalidArgumentException ( '1.($content) parameter must be [scalar] or [callable] type!' ) ; }
|
Protected string or callback
|
55,966
|
protected function bootstrapClassResolution ( $ type , $ class ) { $ result = $ type . ' ' ; $ parts = explode ( ' ' , $ class ) ; foreach ( $ parts as $ part ) { if ( ! strstr ( $ part , $ type ) ) { $ result .= Base :: prefix ( $ part , $ type . '-' ) ; } else { $ result .= $ part ; } $ result .= ' ' ; } return trim ( $ result ) ; }
|
Protected class resolution
|
55,967
|
protected function convertSerializerDataType ( $ datatype ) { if ( $ datatype === 'json' ) { $ this -> settings [ 'serializer' ] [ 'properties' ] = 'dataType:"json",' . EOL ; } elseif ( is_array ( $ datatype ) ) { $ this -> settings [ 'serializer' ] [ 'properties' ] = rtrim ( ltrim ( json_encode ( $ datatype ) , '{' ) , '}' ) . ',' . PHP_EOL ; } }
|
Protected convert serializeer data type
|
55,968
|
protected function transferAttributesAndUnset ( $ type , $ attr ) { $ return = $ this -> settings [ $ type ] [ $ attr ] ?? NULL ; unset ( $ this -> settings [ $ type ] [ $ attr ] ) ; return $ return ; }
|
Protected transfer attributes and unset
|
55,969
|
protected function bootstrapObjectOptions ( String $ selector , $ options , $ type ) { if ( ! empty ( $ options ) ) { $ optionsEncode = json_encode ( $ options ) ; } $ return = '<script>$("' . $ selector . '").' . $ type . '(' . ( $ optionsEncode ?? NULL ) . ')' ; if ( $ parameter = $ this -> transferAttributesAndUnset ( 'attr' , 'on' ) ) { $ return .= '.on(\'' . $ parameter . '\', function(){' . $ this -> transferAttributesAndUnset ( 'attr' , 'onCallback' ) . '})' ; } $ return .= ';</script>' ; $ this -> bootstrapOptions [ $ type ] [ $ selector ] = $ return ; return $ return ; }
|
Protected object options
|
55,970
|
protected function isBootstrapAttribute ( $ attr , $ callback ) { if ( isset ( $ this -> settings [ 'attr' ] [ $ attr ] ) ) { $ attribute = $ this -> settings [ 'attr' ] [ $ attr ] ; if ( $ attribute === str_replace ( '-' , '' , $ attr ) ) { $ attribute = NULL ; } unset ( $ this -> settings [ 'attr' ] [ $ attr ] ) ; $ callback ( $ attribute ) ; } }
|
Protected is bootstrap attribute
|
55,971
|
protected function getModalResource ( String $ resources = 'standart' , $ data , $ directory = 'Modals' ) { return Inclusion \ View :: use ( $ resources , $ data , true , __DIR__ . '/Resources/' . $ directory . '/' ) ; }
|
Protected get modal resource
|
55,972
|
protected function changeFormAttributes ( $ types ) { foreach ( $ types as $ new => $ old ) { $ oldEx = explode ( ':' , $ old ) ; if ( isset ( $ this -> settings [ 'attr' ] [ $ new ] ) ) { unset ( $ this -> settings [ 'attr' ] [ $ new ] ) ; $ this -> settings [ 'attr' ] [ $ oldEx [ 0 ] ] = $ oldEx [ 1 ] ; } } }
|
Protected change form attributes
|
55,973
|
protected function isBootstrapLabelUsage ( $ type ) { if ( $ for = ( $ this -> settings [ 'label' ] [ 'for' ] ?? NULL ) ) { if ( ! $ this -> isCheckboxOrRadio ( $ type ) ) { $ this -> settings [ 'attr' ] [ 'id' ] = $ for ; } } }
|
Protected is bootstrap label usage
|
55,974
|
protected function isBootstrapGroupUsage ( $ type ) { if ( ( $ this -> settings [ 'group' ] [ 'class' ] ?? NULL ) || isset ( $ this -> callableGroup ) ) { if ( ! $ this -> isCheckboxOrRadio ( $ type ) ) { if ( ! isset ( $ this -> settings [ 'attr' ] [ 'class' ] ) ) { $ this -> settings [ 'attr' ] [ 'class' ] = 'form-control' ; } else { $ this -> settings [ 'attr' ] [ 'class' ] .= ' form-control' ; } } } }
|
Protected is bootstrap group usage
|
55,975
|
protected function createBootstrapFormInputElementByType ( $ type , $ value , $ attributes , & $ return ) { $ return = NULL ; if ( $ class = ( $ this -> settings [ 'group' ] [ 'class' ] ?? NULL ) ) { if ( $ this -> isCheckboxOrRadio ( $ type ) ) { if ( $ class === 'form-group' ) { $ class = $ type ; } elseif ( $ class !== $ type ) { $ class = Base :: prefix ( $ class , $ type . ' ' ) ; } } $ return .= '<div class="' . $ class . '">' . EOL ; unset ( $ this -> settings [ 'group' ] ) ; } if ( $ for = ( $ this -> settings [ 'label' ] [ 'for' ] ?? NULL ) ) { if ( ! $ this -> isCheckboxOrRadio ( $ type ) ) { $ this -> createBootstrapInputLabelElement ( $ for , $ return ) ; } else { $ this -> createBootstrapRadioOrCheckboxOpenLabelElement ( $ type , $ radioOrCheckboxLabel , $ return ) ; } unset ( $ this -> settings [ 'label' ] ) ; } $ return .= $ value ; $ this -> isHelpBlockElement ( $ return ) ; $ this -> isBootstrapColumnSize ( $ return ) ; if ( isset ( $ radioOrCheckboxLabel ) ) { $ this -> createBootstrapRadioOrCheckboxCloseLabelElement ( $ for , $ radioOrCheckboxLabel , $ return ) ; } if ( $ class ) { $ return .= '</div>' . EOL ; } }
|
Protected create form input element by type
|
55,976
|
protected function isBootstrapColumnSize ( & $ return ) { if ( $ colsize = $ this -> transferAttributesAndUnset ( 'col' , 'size' ) ) { $ return = $ this -> getHTMLClass ( ) -> class ( Base :: prefix ( $ colsize , 'col-' ) ) -> div ( $ return ) ; } }
|
Protected bootstrap column size
|
55,977
|
protected function createBootstrapRadioOrCheckboxOpenLabelElement ( $ type , & $ radioOrCheckboxLabel , & $ return ) { if ( $ value = $ this -> settings [ 'label' ] [ 'value' ] ) { $ this -> settings [ 'label' ] [ 'value' ] = Base :: prefix ( $ value , $ type . '-' ) ; } $ return .= '<label' . $ this -> createAttribute ( 'class' , $ this -> settings [ 'label' ] [ 'value' ] ) . '>' . EOL ; $ radioOrCheckboxLabel = true ; }
|
Protected create bootstrap radio or checkbox open label element
|
55,978
|
protected function getHttpResponse ( $ request = null , $ response = null ) { $ is_cache = false ; $ cache_type = null ; $ page_cache_config = Lb :: app ( ) -> getPageCacheConfig ( ) ; $ routeInfo = $ this -> route_info ; if ( isset ( $ page_cache_config [ 'controllers' ] [ $ routeInfo [ 'controller' ] ] [ $ routeInfo [ 'action' ] ] ) ) { $ is_cache = true ; $ cache_type = $ page_cache_config [ 'controllers' ] [ $ routeInfo [ 'controller' ] ] [ $ routeInfo [ 'action' ] ] ; if ( $ page_cache = $ this -> getPageCache ( $ cache_type ) ) { return $ page_cache ; } } $ hproseConfig = Lb :: app ( ) -> getHproseConfig ( ) ; $ thriftProviderConfig = Lb :: app ( ) -> getThriftProviderConfig ( ) ; if ( ! empty ( $ thriftProviderConfig [ $ routeInfo [ 'controller' ] ] [ $ routeInfo [ 'action' ] ] ) ) { Route :: thrift ( $ routeInfo ) ; } elseif ( ! empty ( $ hproseConfig [ $ routeInfo [ 'controller' ] ] [ $ routeInfo [ 'action' ] ] ) ) { Route :: hprose ( $ routeInfo , $ request , $ response ) ; } else { ob_start ( ) ; Route :: runWebAction ( $ routeInfo , $ request , $ response ) ; $ page_content = ob_get_contents ( ) ; ob_end_clean ( ) ; $ page_content = $ this -> compressPage ( $ page_content ) ; $ is_cache && $ this -> setPageCache ( $ cache_type , $ page_content ) ; return $ page_content ; } return '' ; }
|
Get http response
|
55,979
|
protected function runWebApp ( ) { $ this -> response -> getSwooleResponse ( ) -> end ( $ this -> getHttpResponse ( $ this -> request , $ this -> response ) ) ; }
|
Run web application
|
55,980
|
private function getUserFromSession ( $ sid ) { $ session = $ this -> entityManager -> getRepository ( "Emeric0101\PHPAngular\Entity\Session" ) -> findBySid ( $ sid ) ; if ( empty ( $ session ) ) { return null ; } $ userLogged = $ this -> entityManager -> find ( "Emeric0101\PHPAngular\Entity\IUser" , $ session [ 0 ] -> getUser ( ) -> getId ( ) ) ; return $ userLogged ; }
|
try to find the logged user with sid
|
55,981
|
public function locate ( $ path , $ currentPath = null , $ first = true ) { if ( file_exists ( $ path ) ) { return $ path ; } if ( null !== $ currentPath && file_exists ( $ currentPath . '/' . $ path ) ) { throw new RuntimeException ( sprintf ( 'You tried to load the file "%s" using a relative path. ' . 'This functionality is not supported due to a limitation in ' . 'Symfony, because then this file cannot be overridden anymore. ' . 'Please pass the absolute Puli path instead.' , $ path ) ) ; } try { $ resource = $ this -> repo -> get ( $ path ) ; while ( $ resource instanceof LinkResource ) { $ resource = $ this -> repo -> get ( $ resource -> getTargetPath ( ) ) ; } if ( ! $ resource instanceof FilesystemResource ) { throw new InvalidArgumentException ( sprintf ( 'The file "%s" is not a local file.' , $ path ) ) ; } return $ first ? $ resource -> getFilesystemPath ( ) : array ( $ resource -> getFilesystemPath ( ) ) ; } catch ( ResourceNotFoundException $ e ) { throw new InvalidArgumentException ( sprintf ( 'The file "%s" could not be found.' , $ path ) , 0 , $ e ) ; } }
|
Returns a full path for a given Puli path .
|
55,982
|
public function removeWordDelimiter ( $ delimiter ) { if ( empty ( $ delimiter ) ) { throw new Exception ( 'Word delimiter cannot be null.' ) ; } if ( is_array ( $ delimiter ) ) { foreach ( $ delimiter as $ delim ) { $ this -> removeWordDelimiter ( $ delim ) ; } } else { if ( ! in_array ( $ delimiter , $ this -> getWordDelimiters ( ) ) ) { throw new Exception ( "Word delimiter '$delimiter' is not in delimiters array." ) ; } $ newArray = array ( ) ; foreach ( $ this -> _wordDelimiters as $ delim ) { if ( $ delim != $ delimiter ) { $ newArray [ ] = $ delim ; } $ this -> _wordDelimiters = $ newArray ; } } return $ this ; }
|
Remove word delimiter
|
55,983
|
private function _replaceDelimiters ( $ s ) { foreach ( $ this -> getWordDelimiters ( ) as $ delimiter ) { if ( $ delimiter == $ this -> getDelimiterReplacement ( ) ) { continue ; } if ( in_array ( $ delimiter , $ this -> getNotReplacedChars ( ) ) ) { continue ; } $ s = str_replace ( $ delimiter , $ this -> getDelimiterReplacement ( ) , $ s ) ; } return $ s ; }
|
replace delimiters with another string
|
55,984
|
public function payload ( array $ input ) : PayloadInterface { $ domain = $ this -> container -> get ( $ this -> id ) ; if ( $ domain instanceof DomainInterface ) { return $ domain -> payload ( $ input ) ; } throw new ContainedDomainTypeException ( $ this -> id , $ domain ) ; }
|
Get the domain from the container then proxy its payload method .
|
55,985
|
protected function getPropertyType ( $ type ) { $ propertyType = ucfirst ( $ type ) ; if ( isset ( self :: $ _propertyTypes [ $ type ] ) ) { $ propertyType = self :: $ _propertyTypes [ $ type ] ; } return $ propertyType ; }
|
Gets the extbase property type by for a given type .
|
55,986
|
public function execute ( $ close = true ) { $ result = curl_exec ( $ this -> curl ) ; $ close && curl_close ( $ this -> curl ) ; return $ result ; }
|
Performs the cURL session .
|
55,987
|
protected function loadTemplateFile ( $ file ) { $ template = @ file_get_contents ( $ this -> templateDir . $ file ) ; if ( $ template === FALSE ) { throw new \ Sonic \ Exception ( 'Unable to load template file ' . $ this -> templateDir . $ file ) ; } return $ template ; }
|
Load a template file and return its contents
|
55,988
|
protected function replaceVars ( $ data ) { foreach ( $ this -> vars as $ key => $ val ) { $ data = str_replace ( $ this -> startDelimiter . $ key . $ this -> endDelimiter , $ val , $ data ) ; } $ data = preg_replace ( '/' . $ this -> startDelimiter . '.*' . $ this -> endDelimiter . '/' , '' , $ data ) ; return $ data ; }
|
Replace variables in the template
|
55,989
|
protected function _parseXml ( $ file , $ query ) { if ( ! file_exists ( $ file ) ) { return array ( ) ; } $ options = defined ( 'LIBXML_COMPACT' ) ? LIBXML_COMPACT : 0 ; $ document = new SimpleXmlElement ( $ file , $ options , true ) ; return $ document -> xpath ( $ query ) ; }
|
Parses a XML file and retrieves data from it using an XPATH query and a given closure .
|
55,990
|
protected static function extend ( $ section , $ content ) { if ( isset ( static :: $ sections [ $ section ] ) ) { static :: $ sections [ $ section ] = str_replace ( '@@parent' , $ content , static :: $ sections [ $ section ] ) ; } else { static :: $ sections [ $ section ] = $ content ; } }
|
Extend the content in a given section .
|
55,991
|
public function radius ( $ meters ) { Assertion :: integer ( $ meters ) ; Assertion :: range ( $ meters , 1 , 100000 ) ; $ this -> radius = $ meters ; return $ this ; }
|
Set the radius in meters .
|
55,992
|
public function addConnection ( array $ settings , string $ name ) : void { $ this -> capsule -> addConnection ( $ settings , $ name ) ; }
|
Adds a new connection to the database eloquent model
|
55,993
|
public static function ensureValid ( $ option ) { if ( is_string ( $ option ) ) { $ option = strtolower ( $ option ) ; } if ( ! self :: isValid ( $ option ) ) { $ option = is_scalar ( $ option ) ? $ option : gettype ( $ option ) ; $ parts = explode ( '\\' , __CLASS__ ) ; $ class = array_pop ( $ parts ) ; throw new EnumException ( sprintf ( '"%s" is not a valid %s option.' , $ option , $ class ) ) ; } return $ option ; }
|
Ensure the provided value is a valid type . Throw an exception if not .
|
55,994
|
public function remove ( $ entity ) { $ meta = $ this -> getMeta ( $ entity ) ; $ hash = $ this -> getHash ( $ entity ) ; if ( $ meta instanceof NodeMeta ) { $ this -> nodeEntitiesToRemove [ $ hash ] = $ entity ; } else { $ this -> relationEntitiesToRemove [ $ hash ] = $ entity ; } }
|
Marks an entity for removal from the database .
|
55,995
|
public function flush ( ) { try { $ this -> writeEntities ( ) ; $ this -> writeLabels ( ) ; $ this -> writeIndexes ( ) ; $ this -> removeEntities ( ) ; $ this -> clearEntities ( ) ; } catch ( Exception $ e ) { $ this -> clearEntities ( ) ; throw $ e ; } }
|
Commits persistent entities to the database .
|
55,996
|
private function removeEntities ( ) { $ deletedRelations = array ( ) ; $ this -> beginBatch ( ) ; foreach ( $ this -> nodeEntitiesToRemove as $ node ) { $ meta = $ this -> getMeta ( $ node ) ; $ id = $ meta -> getPrimaryKey ( ) -> getValue ( $ node ) ; if ( $ id ) { $ entity = $ this -> client -> getNode ( $ id ) ; $ relationships = $ entity -> getRelationships ( ) ; foreach ( $ relationships as $ relationship ) { if ( ! in_array ( $ relationship -> getId ( ) , $ deletedRelations ) ) { $ deletedRelations [ ] = $ relationship -> getId ( ) ; $ relationship -> delete ( ) ; } } $ class = $ meta -> getName ( ) ; $ index = $ this -> getRepository ( $ class ) -> getIndex ( ) ; $ index -> remove ( $ entity ) ; $ entity -> delete ( ) ; } } foreach ( $ this -> relationEntitiesToRemove as $ relation ) { $ meta = $ this -> getMeta ( $ relation ) ; $ id = $ meta -> getPrimaryKey ( ) -> getValue ( $ relation ) ; if ( $ id && ! in_array ( $ id , $ deletedRelations ) ) { $ entity = $ this -> client -> getRelationship ( $ id ) ; $ class = $ meta -> getName ( ) ; $ index = $ this -> getRepository ( $ class ) -> getIndex ( ) ; $ index -> remove ( $ entity ) ; $ entity -> delete ( ) ; } } $ this -> commitBatch ( ) ; }
|
Removes entities in the remove list from the database .
|
55,997
|
private function writeEntities ( ) { $ this -> beginBatch ( ) ; foreach ( $ this -> nodeEntities as $ node ) { $ hash = $ this -> getHash ( $ node ) ; $ this -> everymanNodeCache [ $ hash ] = $ this -> createNode ( $ node ) -> save ( ) ; if ( array_key_exists ( $ hash , $ this -> startNodeRelations ) ) { foreach ( $ this -> startNodeRelations [ $ hash ] as $ relation ) { $ relHash = $ this -> getHash ( $ relation ) ; $ relMeta = $ this -> getMeta ( $ this -> relationEntities [ $ relHash ] ) ; $ prop = $ relMeta -> getStart ( ) ; $ prop -> setValue ( $ this -> relationEntities [ $ relHash ] , $ this -> everymanNodeCache [ $ hash ] ) ; } } if ( array_key_exists ( $ hash , $ this -> endNodeRelations ) ) { foreach ( $ this -> endNodeRelations [ $ hash ] as $ relation ) { $ relHash = $ this -> getHash ( $ relation ) ; $ relMeta = $ this -> getMeta ( $ this -> relationEntities [ $ relHash ] ) ; $ prop = $ relMeta -> getEnd ( ) ; $ prop -> setValue ( $ this -> relationEntities [ $ relHash ] , $ this -> everymanNodeCache [ $ hash ] ) ; } } $ this -> triggerEvent ( self :: RELATION_CREATE , $ node , $ this -> everymanNodeCache [ $ hash ] ) ; } foreach ( $ this -> relationEntities as $ relation ) { $ hash = $ this -> getHash ( $ relation ) ; $ this -> everymanRelationCache [ $ hash ] = $ this -> createRelation ( $ relation ) -> save ( ) ; $ this -> triggerEvent ( self :: RELATION_CREATE , $ relation , $ this -> everymanRelationCache [ $ hash ] ) ; } $ this -> commitBatch ( ) ; }
|
Loops through persistent entities and stores them in the database .
|
55,998
|
private function createNode ( $ entity ) { $ meta = $ this -> getMeta ( $ entity ) ; $ pk = $ meta -> getPrimaryKey ( ) ; $ id = $ pk -> getValue ( $ entity ) ; if ( $ id ) { $ node = $ this -> client -> getNode ( $ id ) ; } else { $ node = $ this -> client -> makeNode ( ) ; } foreach ( $ meta -> getProperties ( ) as $ property ) { $ result = $ property -> getValue ( $ entity ) ; $ node -> setProperty ( $ property -> getName ( ) , $ result ) ; } $ currentDate = $ this -> getCurrentDate ( ) ; if ( ! $ id ) { $ node -> setProperty ( 'creationDate' , $ currentDate ) ; } $ node -> setProperty ( 'updateDate' , $ currentDate ) ; return $ node ; }
|
Creates a Everyman node object from the given entity .
|
55,999
|
private function createRelation ( $ entity ) { $ meta = $ this -> getMeta ( $ entity ) ; $ pk = $ meta -> getPrimaryKey ( ) ; $ id = $ pk -> getValue ( $ entity ) ; $ start = $ meta -> getStart ( ) -> getValue ( $ entity ) ; $ end = $ meta -> getEnd ( ) -> getValue ( $ entity ) ; if ( $ id ) { $ relation = $ this -> client -> getRelationship ( $ id ) ; if ( $ start ) { $ nid = $ start -> getId ( ) ; if ( $ nid != $ relation -> getStartNode ( ) -> getId ( ) ) { throw new Exception ( "You can't change the start node of a saved relation." ) ; } } if ( $ end ) { $ nid = $ end -> getId ( ) ; if ( $ nid != $ relation -> getEndNode ( ) -> getId ( ) ) { throw new Exception ( "You can't change the end node of a saved relation." ) ; } } } else { $ relation = $ this -> client -> makeRelationship ( ) -> setType ( $ meta -> getName ( ) ) ; if ( ! $ start ) { throw new Exception ( "No start node supplied for new " . $ meta -> getName ( ) . " relation." ) ; } if ( ! $ end ) { throw new Exception ( "No end node supplied for new " . $ meta -> getName ( ) . " relation." ) ; } $ relation -> setStartNode ( $ start ) -> setEndNode ( $ end ) ; } foreach ( $ meta -> getProperties ( ) as $ property ) { $ result = $ property -> getValue ( $ entity ) ; $ relation -> setProperty ( $ property -> getName ( ) , $ result ) ; } $ currentDate = $ this -> getCurrentDate ( ) ; if ( ! $ id ) { $ relation -> setProperty ( 'creationDate' , $ currentDate ) ; } $ relation -> setProperty ( 'updateDate' , $ currentDate ) ; return $ relation ; }
|
Creates a Everyman relationship object from the given entity .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.