idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
10,000
function setImplementation ( $ nameOrAlias , $ implement ) { if ( $ this -> has ( $ nameOrAlias ) ) throw new \ Exception ( "Service ({$nameOrAlias}) is already exists;" . "Interface must define before service registration." ) ; if ( is_string ( $ implement ) && ! ( interface_exists ( $ implement ) || class_exists ( $ ...
Set Service Implementation Interface Contract we also be able to get service with defined implementation
10,001
function hasImplementation ( $ nameOrAlias ) { $ nameOrAlias = $ this -> getExtended ( $ nameOrAlias ) ; $ nameOrAlias = $ this -> _normalizeName ( $ nameOrAlias ) ; return ( isset ( $ this -> implementations [ $ nameOrAlias ] ) ? $ this -> implementations [ $ nameOrAlias ] : false ) ; }
Get Implementation Interface of Service Contract
10,002
function set ( iContainerService $ service ) { $ name = $ service -> getName ( ) ; if ( $ name !== null && $ this -> has ( $ name ) && ! $ this -> _attainCService ( $ name ) -> isAllowOverride ( ) ) throw new \ Exception ( "A service by the name or alias ({$name}) already exists and cannot be overridden;" ) ; $ this ->...
Register a service to container
10,003
function has ( $ nameOrAlias ) { if ( ! ( strpos ( $ nameOrAlias , self :: SEPARATOR ) !== false ) ) $ nameOrAlias = $ this -> getExtended ( $ nameOrAlias ) ; if ( strpos ( $ nameOrAlias , self :: SEPARATOR ) !== false ) { $ xService = explode ( self :: SEPARATOR , $ nameOrAlias ) ; $ nameOrAlias = array_pop ( $ xServi...
Check for a registered instance ! It also check for extend aliases
10,004
function getExtended ( $ nameOrAlias ) { while ( $ this -> isExtendedService ( $ nameOrAlias ) ) { $ cAlias = $ this -> _normalizeName ( $ nameOrAlias ) ; $ nameOrAlias = $ this -> aliases [ $ cAlias ] ; if ( strpos ( $ nameOrAlias , self :: SEPARATOR ) !== false ) break ; } return $ nameOrAlias ; }
Get Extend Service Name That This Service Extended Of That
10,005
function extend ( $ newName , $ nameOrAlias ) { $ throw = false ; if ( $ this -> has ( $ newName ) ) { if ( $ this -> isExtendedService ( $ newName ) ) { $ aliasTo = $ this -> getExtended ( $ newName ) ; if ( strstr ( $ aliasTo , self :: SEPARATOR ) ) { $ xService = explode ( self :: SEPARATOR , $ aliasTo ) ; $ nestNam...
Set Alias Name For Registered Service
10,006
function isExtendedService ( $ alias ) { $ cAlias = $ this -> _normalizeName ( $ alias ) ; return isset ( $ this -> aliases [ $ cAlias ] ) ; }
Determine if we have an alias name that extend service
10,007
function initializer ( ) { if ( $ this -> initializer ) return $ this -> initializer ; $ initializer = new InitializerAggregate ( $ this ) ; $ initializer -> addCallable ( function ( $ instance , $ self ) { if ( $ instance instanceof iServicesAware ) $ instance -> setServices ( $ self ) ; } , 10000 ) ; return $ this ->...
Builder Initializer Aggregate
10,008
function nest ( Container $ container , $ namespace = null ) { ( $ namespace !== null ) ? : $ namespace = $ container -> getName ( ) ; if ( $ namespace === null || $ namespace === '' ) throw new \ InvalidArgumentException ( 'Namespace can`t be empty.' ) ; $ cNamespace = $ this -> _normalizeNamespace ( $ namespace ) ; i...
Nest A Container Within
10,009
function from ( $ namespacePath ) { if ( $ namespacePath === '' ) return $ this ; $ cNamespace = $ this -> _normalizeNamespace ( $ namespacePath ) ; if ( false === strstr ( $ cNamespace , self :: SEPARATOR ) ) { if ( ! isset ( $ this -> __nestRight [ $ cNamespace ] ) ) return false ; return $ this -> __nestRight [ $ cN...
Retrieve Nested Container
10,010
function _initializeServiceOrInstance ( $ inService ) { if ( $ inService instanceof iServiceFeatureDelegate ) $ inService -> delegate ( $ this ) ; $ container = $ this ; $ initializers = array ( ) ; while ( $ container -> __nestLeft ) { $ container = $ container -> __nestLeft ; array_push ( $ initializers , $ container...
Initialize object with all parent nested initializers
10,011
protected function _validateImplementation ( $ serviceName , $ instance ) { if ( false === $ implement = $ this -> hasImplementation ( $ serviceName ) ) return ; $ throw = true ; if ( interface_exists ( $ implement ) ) $ throw = ! ( in_array ( $ implement , class_implements ( $ instance ) ) ) ; elseif ( class_exists ( ...
validate interface against attained service instance
10,012
protected function _attainCService ( $ name ) { $ name = $ this -> getExtended ( $ name ) ; $ cName = $ this -> _normalizeName ( $ name ) ; $ return = ( isset ( $ this -> services [ $ cName ] ) ) ? $ this -> services [ $ cName ] : false ; if ( $ return === false ) { foreach ( $ this -> services_aggregate as $ inService...
Achieve Service From Name
10,013
public function getMissionGames ( $ mission , $ user ) { $ games = array ( ) ; $ missionGames = $ this -> findGamesByMission ( $ mission ) ; foreach ( $ missionGames as $ missionGame ) { $ entry = $ this -> checkExistingEntry ( $ missionGame -> getGame ( ) , $ user ) ; $ games [ $ missionGame -> getGame ( ) -> getIdent...
Find games associated to a mission and add the last entry of the user if it exists
10,014
public static function fromArray ( array $ file ) : self { $ url = $ file [ 'file_ext' ] === 'zip' ? $ file [ 'large_file_url' ] : $ file [ 'file_url' ] ; return new self ( $ file [ 'file_size' ] , $ url , self :: getFileTypeByExtension ( $ file [ 'file_ext' ] ) , $ file [ 'image_width' ] , $ file [ 'image_height' ] ) ...
Creates File instance from API response .
10,015
protected static function getFileTypeByExtension ( string $ extension ) : int { switch ( $ extension ) { case 'png' : case 'jpg' : return FileInterface :: TYPE_STATIC_IMAGE ; case 'gif' : return FileInterface :: TYPE_ANIMATED_IMAGE ; case 'webm' : case 'mp4' : case 'zip' : return FileInterface :: TYPE_VIDEO ; default :...
Returns file type constant value by file extension .
10,016
public function getAssets ( ) { $ assets = [ ] ; $ resources = $ this -> config ( ) -> getItem ( 'meliscore/ressources' ) ; $ useBuildAssets = ( bool ) $ resources [ 'build' ] [ 'use_build_assets' ] ; $ cssBuild = $ resources [ 'build' ] [ 'css' ] ; $ jsBuild = $ resources [ 'build' ] [ 'js' ] ; $ webpack = file_get_co...
Returns the assets whether build or not
10,017
protected function getWebPackMixFile ( ) { $ webPackPath = $ _SERVER [ 'DOCUMENT_ROOT' ] ; $ file = self :: WEBPACK_FILE ; $ webpack = $ webPackPath . DIRECTORY_SEPARATOR . $ file ; return $ webpack ; }
Returns the path of webpack . mix . js
10,018
public function getWebPackMixStaticFile ( ) { $ webPackPath = $ _SERVER [ 'DOCUMENT_ROOT' ] ; $ file = self :: WEBPACK_STATIC_FILE ; $ webpack = $ webPackPath . DIRECTORY_SEPARATOR . $ file ; return $ webpack ; }
Returns the path of webpack . mix . static . js
10,019
public function getMergedAssets ( $ useBundle = false ) { $ plugin = new MelisHeadPluginHelper ( $ this -> getServiceLocator ( ) ) ; $ assets = $ plugin -> __invoke ( '/' , $ useBundle ) ; return $ assets ; }
Returns assets from the loaded modules
10,020
private function getCached ( ) { $ syntax = "// Cached assets do not modify\r\nlet cache = [" . PHP_EOL ; foreach ( $ this -> getCachedFiles ( ) as $ file ) { $ syntax .= "'$file'," . PHP_EOL ; } $ syntax .= "];" ; return $ syntax ; }
Used to match in the back - office to check whether the assets has already been compiled or not if not then this will be used to merge to the assets
10,021
public static function loadRelation ( ActiveRecord $ model , $ relationName , $ data , $ requiredData = [ ] ) { $ relationClass = $ model -> getRelation ( $ relationName ) -> modelClass ; return static :: loadMultiple ( @ $ data [ ( new $ relationClass ( ) ) -> formName ( ) ] , $ relationClass , $ model -> $ relationNa...
Loads posted data into model relation models
10,022
public static function loadMultiple ( $ data , $ modelClass , $ models = [ ] , $ requiredData = [ ] ) { $ result = [ 'models' => $ models , 'errors' => [ ] ] ; if ( ! $ data ) { return $ result ; } if ( ! is_array ( $ models ) ) { $ data = [ @ $ models -> id => $ data ] ; $ models = [ @ $ models -> id => $ models ] ; $...
Inserts data into multiple models .
10,023
public static function setUploadedFile ( Model $ model , $ attribute , $ options = [ ] ) { foreach ( $ options as $ name => $ value ) { $ _FILES [ $ model -> formName ( ) ] [ $ name ] [ $ attribute ] = $ value ; } }
Emulates file uploading with existing file .
10,024
public function obtainLock ( ) { $ tries = 0 ; $ waitClosure = $ this -> getWaitClosure ( ) ; do { if ( $ this -> doLock ( ) -> isLocked ( ) ) { return $ this ; } ++ $ tries ; $ waitClosure ( ) ; } while ( $ tries < $ this -> lockTry ) ; return $ this ; }
obtain a lock with retries
10,025
public function notFoundAction ( ) { $ templatePathResolver = $ this -> getServiceLocator ( ) -> get ( 'Zend\View\Resolver\TemplatePathStack' ) ; $ controller = explode ( '\\' , get_class ( $ this ) ) ; $ controllerPath = str_replace ( 'Controller' , '' , end ( $ controller ) ) ; $ controllerPath = strtolower ( preg_re...
Action called if matched action does not exist For this view not to be catched by Zend \ Mvc \ View \ RouteNotFoundStrategy it has to be rendered in the controller . Hence the code below .
10,026
public function bounceAction ( ) { $ availableGames = $ this -> getGameService ( ) -> getAvailableGames ( $ this -> user ) ; $ rssUrl = '' ; $ config = $ this -> getGameService ( ) -> getServiceManager ( ) -> get ( 'config' ) ; if ( isset ( $ config [ 'rss' ] [ 'url' ] ) ) { $ rssUrl = $ config [ 'rss' ] [ 'url' ] ; } ...
This action takes care of bounce page of the game
10,027
public function prizesAction ( ) { if ( count ( $ this -> game -> getPrizes ( ) ) == 0 ) { return $ this -> notFoundAction ( ) ; } $ viewModel = $ this -> buildView ( $ this -> game ) ; return $ viewModel ; }
This action displays the Prizes page associated to the game
10,028
public function prizeAction ( ) { $ prizeIdentifier = $ this -> getEvent ( ) -> getRouteMatch ( ) -> getParam ( 'prize' ) ; $ prize = $ this -> getPrizeService ( ) -> getPrizeMapper ( ) -> findByIdentifier ( $ prizeIdentifier ) ; if ( ! $ prize ) { return $ this -> notFoundAction ( ) ; } $ viewModel = $ this -> buildVi...
This action displays a specific Prize page among those associated to the game
10,029
public function buildView ( $ game ) { if ( $ this -> getRequest ( ) -> isXmlHttpRequest ( ) ) { $ viewModel = new JsonModel ( ) ; if ( $ game ) { $ view = $ this -> addAdditionalView ( $ game ) ; if ( $ view && $ view instanceof \ Zend \ View \ Model \ ViewModel ) { $ viewModel -> setVariables ( $ view -> getVariables...
This method create the basic Game view
10,030
public function canHandle ( $ payload ) { if ( is_object ( $ payload ) && is_a ( $ payload , $ this -> payloadClassName ) ) { return true ; } elseif ( is_string ( $ payload ) && is_subclass_of ( $ payload , $ this -> payloadClassName ) ) { return true ; } else { return false ; } }
Here the DtoConverter can do some additional runtime checks to see whether it can handle the given source data .
10,031
public function getUriBuilder ( ) { $ uriBuilder = $ this -> resourceMapper -> getControllerContext ( ) -> getUriBuilder ( ) ; $ uriBuilder -> reset ( ) -> setFormat ( $ this -> format ) -> setCreateAbsoluteUri ( true ) ; return $ uriBuilder ; }
Get a UriBuilder for creating URIs for a resource .
10,032
protected function runOtherCommand ( $ name , array $ arguments = array ( ) ) { $ arguments [ 'command' ] = $ name ; $ cleanup_command = $ this -> getApplication ( ) -> find ( $ name ) ; $ input = new ArrayInput ( $ arguments ) ; return $ cleanup_command -> run ( $ input , $ this -> io -> getOutput ( ) ) ; }
Runs another command .
10,033
protected function getContainer ( ) { static $ container ; if ( ! isset ( $ container ) ) { $ container_helper = $ this -> getHelper ( 'container' ) ; $ container = $ container_helper -> getContainer ( ) ; } return $ container ; }
Returns container .
10,034
private function _isEqualSelector ( $ node ) { return $ node -> hasAttribute ( $ this -> _attrName ) && $ node -> getAttribute ( $ this -> _attrName ) == $ this -> _value ; }
Equal selector .
10,035
private function _isNotEqualSelector ( $ node ) { return ! $ node -> hasAttribute ( $ this -> _attrName ) || $ node -> getAttribute ( $ this -> _attrName ) != $ this -> _value ; }
Not equal selector .
10,036
private function _isContainSelector ( $ node ) { if ( $ node -> hasAttribute ( $ this -> _attrName ) ) { $ attr = $ node -> getAttribute ( $ this -> _attrName ) ; $ len = strlen ( $ this -> _value ) ; if ( $ len > 0 ) { $ pos = strpos ( $ attr , $ this -> _value ) ; return $ pos !== false ; } } return false ; }
Contain selector .
10,037
private function _isContainWordSelector ( $ node ) { if ( $ node -> hasAttribute ( $ this -> _attrName ) ) { $ items = explode ( " " , trim ( $ node -> getAttribute ( $ this -> _attrName ) ) ) ; foreach ( $ items as $ item ) { if ( preg_match ( "/^\w+$/" , $ item ) && $ this -> _value == $ item ) { return true ; } } } ...
Contain word selector .
10,038
private function _isContainPrefixSelector ( $ node ) { if ( $ node -> hasAttribute ( $ this -> _attrName ) ) { $ attr = $ node -> getAttribute ( $ this -> _attrName ) ; $ len = strlen ( $ this -> _value ) ; if ( $ len > 0 ) { $ pos = stripos ( $ attr , $ this -> _value ) ; return $ pos === 0 && ( strlen ( $ attr ) <= $...
Contain prefix selector .
10,039
private function _isStartWithSelector ( $ node ) { if ( $ node -> hasAttribute ( $ this -> _attrName ) && strlen ( $ this -> _value ) > 0 ) { $ attrValue = $ node -> getAttribute ( $ this -> _attrName ) ; return strpos ( $ attrValue , $ this -> _value ) === 0 ; } return false ; }
Start with selector .
10,040
private function _isEndWithSelector ( $ node ) { if ( $ node -> hasAttribute ( $ this -> _attrName ) ) { $ len = strlen ( $ this -> _value ) ; if ( $ len > 0 ) { $ attr = $ node -> getAttribute ( $ this -> _attrName ) ; $ attrLen = strlen ( $ attr ) ; return $ len <= $ attrLen && strpos ( $ attr , $ this -> _value , $ ...
End with selector .
10,041
private function _isAttrSelector ( $ node ) { $ ret = false ; if ( $ this -> _op == CssParserFilterAttr :: EQUAL_SELECTOR ) { $ ret = $ this -> _isEqualSelector ( $ node ) ; } elseif ( $ this -> _op == CssParserFilterAttr :: NOT_EQUAL_SELECTOR ) { $ ret = $ this -> _isNotEqualSelector ( $ node ) ; } elseif ( $ this -> ...
Is an attribute selector?
10,042
public function schedule ( $ postId ) { if ( $ postId !== 'options' || ! isset ( $ _GET [ 'page' ] ) || $ _GET [ 'page' ] !== 'acf-options-feedback-options' ) { return ; } wp_unschedule_hook ( 'customer-feedback/email_summary' ) ; wp_clear_scheduled_hook ( 'customer-feedback/email_summary' ) ; $ summaries = get_field (...
Schedule the stuff
10,043
public function getCachedResult ( $ interval ) { if ( ! empty ( self :: $ resultCache [ $ interval ] ) ) { return self :: $ resultCache [ $ interval ] ; } return false ; }
Get s cache response if any
10,044
public function renderReport ( $ from = null , $ to = null , $ return = false ) { if ( isset ( $ _GET [ 'date_from' ] ) && ! empty ( $ _GET [ 'date_from' ] ) ) { $ from = $ _GET [ 'date_from' ] ; } if ( isset ( $ _GET [ 'date_to' ] ) && ! empty ( $ _GET [ 'date_to' ] ) ) { $ to = $ _GET [ 'date_to' ] ; } if ( isset ( $...
Renders summary report
10,045
public function getDataBetween ( $ from = null , $ to = null ) { $ answerPosts = $ this -> getAnswerPosts ( $ from , $ to ) ; $ yesno = array ( 'yes' => 0 , 'no' => 0 ) ; $ pending = array ( ) ; foreach ( $ answerPosts as $ post ) { $ topics = wp_get_post_terms ( $ post -> ID , 'feedback_topic' ) ; $ feedback_topics = ...
Gets relevant data for the summary
10,046
public function getAnswerPosts ( $ from = null , $ to = null ) { $ answerPosts = array ( 'posts_per_page' => - 1 , 'post_type' => 'customer-feedback' , 'post_status' => array ( 'publish' , 'pending' , 'draft' ) , ) ; $ answerPosts [ 'date_query' ] = array ( 'inclusive' => true ) ; if ( ! is_null ( $ from ) ) { $ answer...
Get answer posts between dates
10,047
public function beforeSave ( ) { if ( $ this -> owner -> hasAttribute ( $ this -> attribute ) && ! $ this -> owner -> { $ this -> attribute } ) { $ this -> owner -> setAttribute ( $ this -> attribute , Yii :: $ app -> user -> identity -> { $ this -> attribute } ) ; } }
Automatically sets owners owner_id from current user owner_id
10,048
public function search ( $ params ) { $ owner = $ this -> owner ; $ query = $ owner :: find ( ) ; $ t = is_array ( $ query -> from ) ? key ( $ query -> from ) : $ query -> from ; return $ query -> filterWhere ( $ params ) -> andWhere ( [ "$t.owner_id" => Yii :: $ app -> user -> identity -> { $ this -> attribute } ] ) ;...
Searches models matching current user owner_id
10,049
public function relationList ( $ relationName , $ index = 'id' , $ name = null ) { $ model = $ this -> owner ; $ class = $ model -> getRelation ( $ relationName ) -> modelClass ; $ item = new $ class ( ) ; $ relation = method_exists ( $ item , 'search' ) ? $ item -> search ( [ ] ) : $ class :: find ( ) ; $ name = $ nam...
Gets relation data list for dropdown
10,050
public static function filter ( $ value = null , bool $ allowNull = false ) { if ( self :: valueIsNullAndValid ( $ allowNull , $ value ) ) { return null ; } self :: validateString ( $ value ) ; return self :: filterUrl ( $ value ) ; }
Filter an url
10,051
public function name ( $ name = null ) { if ( $ name !== null ) { if ( preg_match ( "/[=,; \t\r\n\013\014]/" , $ name ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Cookie name "%s" contains invalid characters' , $ name ) ) ; } if ( empty ( $ name ) ) { throw new \ InvalidArgumentException ( 'Cookie name canno...
Returns cookie name
10,052
public function value ( $ value = null ) { if ( $ value !== null ) { $ this -> value = $ value ; } return ( string ) $ this -> value ; }
Returns cookie value .
10,053
public function ttl ( $ ttl = null ) { if ( $ ttl === null ) { return ( int ) $ this -> ttl ; } if ( $ ttl instanceof \ DateTime ) { return $ this -> ttl = $ ttl -> format ( 'U' ) ; } return $ this -> ttl = time ( ) + ( int ) $ ttl ; }
Returns cookie TTL
10,054
public function path ( $ path = null ) { if ( $ path !== null ) { $ this -> path = $ path ; } return ( string ) $ this -> path ; }
Returns cookie path
10,055
public function secure ( $ secure = null ) { if ( $ secure !== null ) { $ this -> secure = ( bool ) $ secure ; } return ( bool ) $ this -> secure ; }
Sets if cookie is secure
10,056
public function httpOnly ( $ httpOnly = null ) { if ( $ httpOnly !== null ) { $ this -> httpOnly = ( bool ) $ httpOnly ; } return ( bool ) $ this -> httpOnly ; }
Sets if cookie is http only
10,057
public function push ( ... $ elements ) : self { foreach ( $ elements as $ element ) { $ this -> validate ( $ element ) ; $ this -> elements [ ] = $ element ; } return $ this ; }
Pushes one or more elements on to the end of the sequence .
10,058
public function unshift ( ... $ elements ) { foreach ( $ elements as $ element ) { $ this -> validate ( $ element ) ; } return \ array_unshift ( $ this -> elements , ... $ elements ) ; }
Prepends one or more elements to the beginning of the sequence .
10,059
protected function fetchConfiguration ( $ parameter ) { $ configuration = $ this -> configurationRepository -> fetchParameter ( $ parameter ) ; if ( null === $ configuration ) { $ exception = array ( 'message' => 'exception_parameter_does_not_exist' , 'parameters' => array ( '%parameter%' => $ parameter , ) , ) ; throw...
Fetches the configuration record for the requested parameter
10,060
public function register ( array $ aOptions = array ( ) ) { $ sentry = jaxon ( ) -> sentry ( ) ; $ sentry -> addClassOptions ( $ this -> appConfig ) ; $ sentry -> mergeClassOptions ( $ aOptions ) ; $ sentry -> register ( ) ; }
Register the Jaxon classes .
10,061
private function clearLogs ( ) { foreach ( $ this -> logger -> getHandlers ( ) as $ handler ) { if ( $ handler instanceof FingersCrossedHandler ) { $ handler -> clear ( ) ; } } }
Clear logs on fingers crossed logger handlers .
10,062
private function parseRequest ( $ request ) { if ( ! isset ( $ request -> id ) ) return ; $ res = ( object ) array ( 'name' => isset ( $ request -> name ) ? $ request -> name : '' , 'version' => $ request -> version , 'slug' => $ request -> slug , 'download_link' => $ request -> download_link , 'tested' => isset ( $ re...
Convert API response to wordpress plugins API needed object
10,063
protected function getImageUrlOrDefault ( ) { $ imagePath = $ this -> entity -> path ; if ( ! Storage :: exists ( $ imagePath ) ) { $ imagePath = $ this -> imgNotFound ( ) ; } return Storage :: url ( $ imagePath ) ; }
Get the path of the image or the path to the default image .
10,064
protected function setup ( ) : void { if ( null === $ this -> worker ) { $ worker = new \ GearmanWorker ( ) ; $ worker -> setTimeout ( $ this -> timeout ) ; if ( empty ( $ this -> servers ) ) { try { if ( ! $ worker -> addServer ( ) ) { throw new \ GearmanException ( 'GearmanWorker::addServer returned false.' , GEARMAN...
Creates a gearman worker sets the timeout and adds the servers . At least one server must connect successfully otherwise an exception is thrown .
10,065
protected function work ( ) : void { if ( @ $ this -> worker -> work ( ) || $ this -> worker -> returnCode ( ) == GEARMAN_IO_WAIT || $ this -> worker -> returnCode ( ) == GEARMAN_NO_JOBS ) { if ( $ this -> worker -> returnCode ( ) == GEARMAN_SUCCESS ) { return ; } if ( ! @ $ this -> worker -> wait ( ) ) { if ( $ this -...
Runs the gearman worker process .
10,066
protected function teardown ( ) : void { if ( $ this -> worker ) { @ $ this -> worker -> unregisterAll ( ) ; $ this -> worker = null ; } }
Unregisters all functions from the gearman worker and then nullifies the worker .
10,067
public function getData ( ) { $ data = array ( ) ; foreach ( get_object_vars ( $ this ) as $ key => $ value ) { if ( strpos ( $ key , '__' ) !== 0 ) { $ data [ $ key ] = $ value ; } } return $ data ; }
Get the data of the job for sending to the new process .
10,068
public function fire ( $ event , $ subject = null , $ message = null ) { return $ this -> dispatcher ( ) -> fire ( $ event , $ subject , $ message ) ; }
Fires passed event and returns its response or null if no response passed and received
10,069
private function eventMsg ( \ Exception $ exception ) { return sprintf ( '%s (%s line:%s)' , $ exception -> getMessage ( ) , $ exception -> getFile ( ) , $ exception -> getLine ( ) ) ; }
Builds event message from exception
10,070
protected function callController ( $ controller ) { if ( is_string ( $ controller ) && strpos ( $ controller , self :: SEPARATOR ) !== false ) { list ( $ controller , $ action ) = explode ( self :: SEPARATOR , $ controller ) ; $ response = $ this -> callClassController ( $ controller , $ action ) ; } elseif ( is_calla...
Calls controller from callable or class
10,071
private function callClassController ( $ controller , $ action ) { if ( ! class_exists ( $ controller ) ) { throw new AppException ( sprintf ( 'Invalid class name or class "%s" does not exists' , $ controller ) ) ; } $ instance = new $ controller ( $ this ) ; if ( $ res = $ this -> callMethod ( $ instance , 'before' ) ...
Calls class method as controller
10,072
private function callMethod ( $ instance , $ method ) { if ( ! method_exists ( $ instance , $ method ) || ! is_callable ( [ $ instance , $ method ] ) ) { return false ; } return call_user_func ( [ $ instance , $ method ] ) ; }
Calls controllers method if exists otherwise returns false
10,073
protected function updateHostHeaderFromUri ( ) { if ( $ host = $ this -> uri -> getHost ( ) ) { if ( ( $ port = $ this -> uri -> getPort ( ) ) !== null ) { $ host .= ':' . $ port ; } $ this -> headers -> set ( 'Host' , $ host ) ; } }
Update Host header from Uri
10,074
public function has ( $ offset = null ) { if ( $ offset === null ) { return $ this -> count ( ) > 0 ; } return array_key_exists ( $ offset , $ this -> storage ) ; }
Returns true if bag has cookie with set name
10,075
public function asArray ( ) { $ cookies = [ ] ; foreach ( array_filter ( $ this -> storage ) as $ cookie ) { $ cookies [ ] = 'Set-Cookie: ' . ( string ) $ cookie ; } return $ cookies ; }
Builds array of cookie strings
10,076
public function setCodeLength ( $ value ) { $ this -> codeLength = filter_var ( $ value , FILTER_VALIDATE_INT , array ( 'options' => array ( 'min_range' => self :: CODE_LENGTH_DEFAULT , 'max_range' => self :: CODE_LENGTH_MAX ) ) ) ; if ( ! $ this -> codeLength ) { throw new \ Exception ( 'The code length have to be bet...
Set the code length .
10,077
public function setCallbackUrl ( $ value ) { $ this -> callbackUrl = filter_var ( $ value , FILTER_VALIDATE_URL , FILTER_FLAG_HOST_REQUIRED ) ; if ( ! $ this -> callbackUrl ) { throw new \ Exception ( 'Invalid URL.' ) ; } return $ this ; }
Set the Callback URL .
10,078
public function setSenderId ( $ value ) { if ( is_numeric ( $ value ) ) { if ( strlen ( $ value ) <= self :: SENDER_ID_NUMERIC_MAX ) { $ this -> senderId = $ value ; } else { throw new \ Exception ( 'The sender ID is too long (' . self :: SENDER_ID_NUMERIC_MAX . ' Max.).' ) ; } } elseif ( ctype_alnum ( $ value ) ) { if...
Set the sender ID .
10,079
public function set ( $ variableName , $ value ) { $ authorizedSetters = array ( 'clientRef' , 'phoneNumber' , 'codeLength' , 'codeType' , 'caseSensitive' , 'callbackUrl' , 'senderId' , 'messageTemplate' ) ; if ( in_array ( $ variableName , $ authorizedSetters ) ) { $ name = 'set' . ucfirst ( $ variableName ) ; $ this ...
Set the available variables in the object .
10,080
public function serialize ( VisitorInterface $ visitor , ? UuidInterface $ uuid , Type $ type , Context $ context ) : ? string { if ( null === $ uuid ) { return $ visitor -> visitNull ( null , Type :: null ( ) , $ context ) ; } return $ visitor -> visitString ( $ uuid -> toString ( ) , $ type , $ context ) ; }
Serializes an Uuid object into a string .
10,081
public function deserialize ( VisitorInterface $ visitor , $ data , Type $ type , Context $ context ) : ? UuidInterface { if ( empty ( $ data ) ) { return $ visitor -> visitNull ( null , Type :: null ( ) , $ context ) ; } return Uuid :: fromString ( $ data ) ; }
Converts a string representation into an Uuid object .
10,082
public function dir_opendir ( $ path , $ options ) { $ url = $ this -> parseUrl ( $ path ) ; if ( empty ( $ url [ 'host' ] ) ) { trigger_error ( 'Container name is required.' , E_USER_WARNING ) ; return FALSE ; } try { $ this -> initializeObjectStorage ( ) ; $ container = $ this -> store -> container ( $ url [ 'host' ]...
Open a directory for reading .
10,083
public function dir_readdir ( ) { if ( count ( $ this -> dirListing ) <= $ this -> dirIndex ) { return FALSE ; } $ curr = $ this -> dirListing [ $ this -> dirIndex ] ; $ this -> dirIndex ++ ; if ( $ curr instanceof \ HPCloud \ Storage \ ObjectStorage \ Subdir ) { $ fullpath = $ curr -> path ( ) ; } else { $ fullpath = ...
Read an entry from the directory .
10,084
public function rename ( $ path_from , $ path_to ) { $ this -> initializeObjectStorage ( ) ; $ src = $ this -> parseUrl ( $ path_from ) ; $ dest = $ this -> parseUrl ( $ path_to ) ; if ( $ src [ 'scheme' ] != $ dest [ 'scheme' ] ) { trigger_error ( "I'm too stupid to copy across protocols." , E_USER_WARNING ) ; } if ( ...
Rename a swift object .
10,085
public function stream_close ( ) { try { $ this -> writeRemote ( ) ; } catch ( \ HPCloud \ Exception $ e ) { trigger_error ( 'Error while closing: ' . $ e -> getMessage ( ) , E_USER_NOTICE ) ; return FALSE ; } unset ( $ this -> obj ) ; fclose ( $ this -> objStream ) ; }
Close a stream writing if necessary .
10,086
public function stream_flush ( ) { try { $ this -> writeRemote ( ) ; } catch ( \ HPCloud \ Exception $ e ) { syslog ( LOG_WARNING , $ e ) ; trigger_error ( 'Error while flushing: ' . $ e -> getMessage ( ) , E_USER_NOTICE ) ; return FALSE ; } }
Initiate saving data on the remote object storage .
10,087
protected function writeRemote ( ) { $ contentType = $ this -> cxt ( 'content_type' ) ; if ( ! empty ( $ contentType ) ) { $ this -> obj -> setContentType ( $ contentType ) ; } if ( $ this -> isNeverDirty ) { return ; } if ( $ this -> isDirty ) { $ position = ftell ( $ this -> objStream ) ; rewind ( $ this -> objStream...
Write data to the remote object storage .
10,088
public function stream_seek ( $ offset , $ whence ) { $ ret = fseek ( $ this -> objStream , $ offset , $ whence ) ; return $ ret === 0 ; }
Perform a seek .
10,089
public function stream_set_option ( $ option , $ arg1 , $ arg2 ) { switch ( $ option ) { case STREAM_OPTION_BLOCKING : return stream_set_blocking ( $ this -> objStream , $ arg1 ) ; case STREAM_OPTION_READ_TIMEOUT : return stream_set_timeout ( $ this -> objStream , $ arg1 , $ arg2 ) ; case STREAM_OPTION_WRITE_BUFFER : r...
Set options on the underlying stream .
10,090
public function unlink ( $ path ) { $ url = $ this -> parseUrl ( $ path ) ; if ( empty ( $ url [ 'host' ] ) ) { trigger_error ( 'Container name is required.' , E_USER_WARNING ) ; return FALSE ; } if ( empty ( $ url [ 'path' ] ) ) { trigger_error ( 'Path is required.' , E_USER_WARNING ) ; return FALSE ; } try { $ this -...
Unlink a file .
10,091
protected function generateStat ( $ object , $ container , $ size ) { $ mode = $ container -> acl ( ) -> isPublic ( ) ? 33277 : 33272 ; if ( function_exists ( 'posix_geteuid' ) ) { $ uid = posix_geteuid ( ) ; $ gid = posix_getegid ( ) ; } else { $ uid = 0 ; $ gid = 0 ; } if ( $ object instanceof \ HPCloud \ Storage \ O...
Generate a reasonably accurate STAT array .
10,092
protected function setMode ( $ mode ) { $ mode = strtolower ( $ mode ) ; $ this -> isBinary = strpos ( $ mode , 'b' ) !== FALSE ; $ this -> isText = strpos ( $ mode , 't' ) !== FALSE ; $ mode = preg_replace ( '/[bt]?/' , '' , $ mode ) ; switch ( $ mode ) { case 'r+' : $ this -> isWriting = TRUE ; case 'r' : $ this -> i...
Set the fopen mode .
10,093
protected function cxt ( $ name , $ default = NULL ) { if ( is_resource ( $ this -> context ) && empty ( $ this -> contextArray ) ) { $ cxt = stream_context_get_options ( $ this -> context ) ; if ( ! empty ( $ cxt [ $ this -> schemeName ] ) ) { $ this -> contextArray = $ cxt [ $ this -> schemeName ] ; } elseif ( ! empt...
Get an item out of the context .
10,094
protected function parseUrl ( $ url ) { $ res = parse_url ( $ url ) ; foreach ( $ res as $ key => $ val ) { if ( $ key == 'host' ) { $ res [ $ key ] = urldecode ( $ val ) ; } elseif ( $ key == 'path' ) { if ( strpos ( $ val , '/' ) === 0 ) { $ val = substr ( $ val , 1 ) ; } $ res [ $ key ] = urldecode ( $ val ) ; } } r...
Parse a URL .
10,095
protected function initializeObjectStorage ( ) { $ token = $ this -> cxt ( 'token' ) ; $ account = $ this -> cxt ( 'account' ) ; $ key = $ this -> cxt ( 'key' , $ this -> cxt ( 'secret' ) ) ; $ tenantId = $ this -> cxt ( 'tenantid' ) ; $ tenantName = $ this -> cxt ( 'tenantname' ) ; $ authUrl = $ this -> cxt ( 'endpoin...
Based on the context initialize the ObjectStorage .
10,096
protected function initializeCDN ( $ token , $ catalog ) { $ cdn = $ this -> cxt ( 'use_cdn' , FALSE ) ; if ( empty ( $ cdn ) ) { return FALSE ; } elseif ( $ cdn instanceof \ HPCloud \ Storage \ CDN ) { $ this -> cdn = $ cdn ; } else { if ( empty ( $ catalog ) ) { $ ident = $ this -> authenticate ( ) ; $ catalog = $ id...
Initialize CDN service .
10,097
protected function getUserHomeDirectory ( ) { if ( defined ( 'PHP_WINDOWS_VERSION_MAJOR' ) ) { if ( ! getenv ( 'APPDATA' ) ) { throw new ApplicationException ( 'The APPDATA environment variable must be set to run correctly.' ) ; } return strtr ( getenv ( 'APPDATA' ) , '\\' , '/' ) ; } if ( ! getenv ( 'HOME' ) ) { throw...
Returns path to user s home directory .
10,098
public function toXML ( DOMDocument $ dom ) { if ( ! $ this -> XMLStorable ) { return false ; } $ itemNode = $ dom -> createElement ( 'item' ) ; foreach ( $ this -> attributes as $ attrName => $ attrValue ) { switch ( $ attrName ) { case 'id' : $ itemNode -> setAttribute ( 'id' , $ attrValue ) ; break ; case 'action' :...
Creates DOMElement with item data
10,099
public static function createFromXML ( DOMElement $ node ) { $ newObj = new eZPageBlockItem ( ) ; if ( $ node -> hasAttributes ( ) ) { foreach ( $ node -> attributes as $ attr ) { $ newObj -> setAttribute ( $ attr -> name , $ attr -> value ) ; } } foreach ( $ node -> childNodes as $ node ) { if ( $ node -> nodeType == ...
Creates and return eZPageBlockItem object from given XML