idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
13,300
public function postPersist ( LifecycleEventArgs $ args ) : void { $ object = $ args -> getObject ( ) ; if ( ! $ object instanceof PublishableInterface ) { return ; } if ( $ object -> isPublished ( ) ) { $ event = new EntityPublishedEvent ( $ object ) ; $ this -> event_dispatcher -> dispatch ( EntityPublishedEvent :: N...
If an object is added as published fire published event .
13,301
public function preUpdate ( LifecycleEventArgs $ args ) : void { $ object = $ args -> getObject ( ) ; if ( ! $ object instanceof PublishableInterface ) { return ; } if ( $ object -> isActive ( ) && ! $ object -> isPublished ( ) ) { $ object -> setPublished ( true ) ; } }
Act before updating an object .
13,302
public function postUpdate ( LifecycleEventArgs $ args ) : void { $ object = $ args -> getObject ( ) ; if ( ! $ object instanceof PublishableInterface ) { return ; } $ uow = $ args -> getObjectManager ( ) -> getUnitOfWork ( ) ; $ changeset = $ uow -> getEntityChangeset ( $ object ) ; if ( isset ( $ changeset [ 'publish...
If an object is updated and published fire published event .
13,303
public function run ( ) : string { if ( null === $ this -> languageModel ) { throw new InvalidConfigException ( 'Language model is not defined.' ) ; } return $ this -> render ( 'tableMultilanguage' , [ 'languageModel' => $ this -> languageModel , 'fields' => $ this -> fields , 'model' => $ this -> model , ] ) ; }
Starts output for each specified field of the translation list .
13,304
protected function set_data ( array $ contents = [ ] ) { $ definition = [ 'REQUEST_METHOD' => [ 'filter' => FILTER_CALLBACK , 'options' => function ( $ method ) { return \ strtoupper ( \ filter_var ( $ method , FILTER_SANITIZE_STRING ) ) ; } , ] , 'QUERY_STRING' => FILTER_UNSAFE_RAW , 'REMOTE_ADDR' => FILTER_VALIDATE_I...
Populate the server bag .
13,305
public function getFlowUp ( $ id , $ where = [ ] ) { $ q = [ 'pid' => $ id ] ; $ res = [ ] ; while ( $ q [ 'pid' ] ) { $ res [ ] = $ q = q_assoc_row ( $ this -> getSQL ( $ this -> columns , '`t`.`id`="' . $ q [ 'pid' ] . '"' . ( $ where ? ' AND ' . implode ( ' AND ' , $ where ) : NULL ) . '' ) ) ; } return array_revers...
Get recursive from childe to top parent
13,306
public static function spaceless ( string $ string ) : string { $ string = self :: trim ( $ string ) ; $ string = self :: replace ( $ string , '#\s{2,}#' , ' ' ) ; return $ string ; }
Remove white characters from the beginning and end of a string and convert multiple spaces between characters to one space
13,307
public function restrictTo ( string $ type ) { if ( count ( $ this ) > 0 ) { throw new CollectionException ( 'Type restriction could not be applied to a non empty collection' ) ; } $ this -> type = $ type ; return $ this ; }
Restricts the values of the collection to a given type
13,308
public function set ( $ key , $ value ) { $ this -> checkRestriction ( $ value ) ; if ( ! is_null ( $ key ) ) { $ this -> value [ $ key ] = $ value ; } else { $ this -> value [ ] = $ value ; } return $ this ; }
Define a key and associate a value to it
13,309
public function filter ( callable $ callback = null ) { if ( is_null ( $ callback ) ) { $ this -> setInternalValue ( array_filter ( $ this -> getInternalValue ( ) ) ) ; } else { $ this -> setInternalValue ( array_filter ( $ this -> getInternalValue ( ) , $ callback , ARRAY_FILTER_USE_BOTH ) ) ; } return $ this ; }
Modify the collection using a callable to determine which values to include
13,310
public function first ( ) { if ( $ this -> count ( ) == 0 ) { throw new UnderflowException ( 'Unexpected empty state' ) ; } $ values = $ this -> toArray ( ) ; reset ( $ values ) ; $ lastKey = key ( $ values ) ; return $ this -> get ( $ lastKey ) ; }
Return the first element of the collection
13,311
public function contains ( $ value , bool $ strict = false ) : bool { return ( is_bool ( $ this -> search ( $ value , $ strict ) ) ? false : true ) ; }
Determines whether the collection contains a given value
13,312
public function each ( callable $ callable ) { foreach ( $ this -> value as $ key => & $ val ) { try { $ callable ( $ val , $ key ) ; } catch ( BreakException $ e ) { break ; } } return $ this ; }
Iterates collection . Value is passed by reference in the callback .
13,313
public function flip ( ) { $ unvaluedEntries = ( clone $ this ) -> filter ( function ( $ value ) { return ! $ value ; } ) -> keys ( ) ; $ collection = ( clone $ this ) -> filter ( ) ; $ this -> setInternalValue ( array_merge ( array_flip ( $ collection -> toArray ( ) ) , $ unvaluedEntries -> toArray ( ) ) ) ; return $ ...
Modify the collection with the keys and values of the current collection inverted
13,314
public function join ( string $ glue = ' ' ) : Str { return new Str ( implode ( $ glue , $ this -> values ( ) -> toArray ( ) ) ) ; }
Joins all values together as a string
13,315
public function last ( ) { if ( $ this -> count ( ) == 0 ) { throw new UnderflowException ( 'Unexpected empty state' ) ; } $ values = $ this -> toArray ( ) ; end ( $ values ) ; $ lastKey = key ( $ values ) ; return $ this -> get ( $ lastKey ) ; }
Return the last element of the collection
13,316
public function map ( callable $ callback ) : Collection { $ values = [ ] ; foreach ( $ this -> getInternalValue ( ) as $ key => $ value ) { $ values [ $ key ] = $ callback ( $ value , $ key ) ; } return new static ( $ values , $ this -> type ) ; }
Returns a new collection which is the result of applying a callback to each value of the collection .
13,317
public function merge ( $ value ) { $ value = ( self :: cast ( $ value , $ this -> type ) ) -> getInternalValue ( ) ; $ this -> setInternalValue ( array_merge ( $ this -> getInternalValue ( ) , $ value ) ) ; return $ this ; }
Modify the collection with the result of associating all keys of a given value with their corresponding values combined with the current instance .
13,318
public function prepend ( ... $ values ) { if ( ! empty ( $ values ) ) { $ this -> checkRestriction ( ... $ values ) ; array_unshift ( $ this -> value , ... $ values ) ; } return $ this ; }
Adds values to the front of the sequence
13,319
public function remove ( $ value , $ strict = false ) { while ( $ index = $ this -> search ( $ value , $ strict ) ) { $ this -> delete ( $ index ) ; } return $ this ; }
Remove an element of the collection with its value
13,320
public function rename ( $ from , $ to ) { $ arrayCopy = $ this -> getInternalValue ( ) ; if ( ! array_key_exists ( $ from , $ arrayCopy ) ) { throw new CollectionException ( sprintf ( 'The key "%s" was not found.' , $ from ) ) ; } $ keys = array_keys ( $ arrayCopy ) ; $ keys [ array_search ( $ from , $ keys ) ] = $ to...
Modify the collection with the value of a key renamed by a new one
13,321
public function search ( $ value , bool $ strict = false ) { if ( ! $ strict ) { $ values = $ this -> copy ( ) ; $ values -> apply ( function ( $ value ) { if ( is_string ( $ value ) ) { return strtolower ( $ value ) ; } return $ value ; } ) ; $ value = strtolower ( $ value ) ; } else { $ values = $ this ; } return arr...
Search a value in the Collection and return the associated key
13,322
public function union ( $ value ) { $ value = Collection :: cast ( $ value , $ this -> type ) -> getInternalValue ( ) ; $ this -> setInternalValue ( $ this -> getInternalValue ( ) + $ value ) ; return $ this ; }
Modify the collection using values from the current instance and another map
13,323
public static function cast ( $ collection , string $ restrictTo = null ) { if ( $ collection instanceof Collection ) { return $ collection ; } return new static ( $ collection , $ restrictTo ) ; }
Convert a value to a Collection instance
13,324
protected function getValueType ( $ value ) { switch ( true ) { case is_scalar ( $ value ) : $ type = gettype ( $ value ) ; break ; case is_array ( $ value ) : $ type = 'array' ; break ; case is_object ( $ value ) : $ type = get_class ( $ value ) ; break ; case is_resource ( $ value ) : $ type = 'resource' ; break ; de...
Returns the type of a value
13,325
public function render ( Descriptor $ descriptor ) { $ style = file_get_contents ( __DIR__ . '/Assets/style.css' ) ; $ styleTag = new Tag ( 'style' , $ style ) ; $ topologyTag = new Tag ( ) ; $ topologyTag -> addClass ( 'topology' ) ; return $ styleTag -> render ( ) . $ topologyTag -> render ( $ this -> renderElement (...
Render the topology
13,326
protected function renderChildren ( Descriptor $ descriptor ) { $ counter = 1 ; $ parts = [ ] ; $ total = $ descriptor -> getChildrenNumber ( ) ; $ tagsLocator = $ this -> getTagsLocator ( ) ; $ linkUp = $ tagsLocator -> linkUp -> render ( ) ; $ linkDown = $ tagsLocator -> linkDown -> render ( ) ; $ wrapper = $ tagsLoc...
Render the element s children
13,327
protected function renderChildElement ( Descriptor $ descriptor , $ linkTitle ) { $ element = $ this -> renderElement ( $ descriptor ) ; $ link = $ this -> getTagsLocator ( ) -> get ( 'link' ) ; if ( is_string ( $ linkTitle ) ) { return $ element . $ link -> render ( $ linkTitle ) ; } return $ element . $ link -> rende...
Render the element as a child
13,328
protected function renderElementInner ( Descriptor $ descriptor ) { $ tagsLocator = $ this -> getTagsLocator ( ) ; $ elementTag = new Tag ( ) ; $ elementTag -> addClass ( 'topology-element' ) ; $ type = $ descriptor -> getType ( ) ; if ( isset ( static :: $ types [ $ type ] ) ) { $ elementTag -> addClass ( static :: $ ...
Render the element s inner parts
13,329
protected function renderHeaderContent ( Descriptor $ descriptor ) { $ tagsLocator = $ this -> getTagsLocator ( ) ; $ title = '' ; if ( $ descriptor -> hasLabel ( ) ) { $ label = htmlspecialchars ( $ descriptor -> getLabel ( ) ) ; $ title .= $ tagsLocator -> label -> render ( $ label ) ; } $ title .= htmlspecialchars (...
Rebder the element s header content
13,330
protected function renderBodyContent ( Descriptor $ descriptor ) { $ content = new Table ( ) ; $ content -> addClass ( 'topology-props' ) ; foreach ( $ descriptor -> getProperties ( ) as $ property => $ value ) { $ value = htmlspecialchars ( $ value ) ; if ( is_numeric ( $ property ) ) { $ content [ ] = [ $ value , '' ...
Render the element s body content
13,331
public function getTagsLocator ( ) { if ( $ this -> tagsLocator !== null ) { return $ this -> tagsLocator ; } $ container = new Container ( ) ; $ container -> header = function ( ) { return new Tag ( 'div' , null , 'topology-header' ) ; } ; $ container -> body = function ( ) { return new Tag ( 'div' , null , 'topology-...
Get the tags locator
13,332
public function init ( $ name , $ requestType , $ responseType , $ responseWrapper , $ method , $ urlBuildMethod , $ baseUrl , $ port , array $ parameters , array $ addsOn = array ( ) , array $ requestHeaders = array ( ) ) { $ this -> name = $ name ; $ this -> requestType = $ requestType ; $ this -> responseType = $ re...
Initializes a request object
13,333
protected function setRequestUri ( array $ parameters = array ( ) ) { $ uri = $ this -> constructActionUrl ( $ parameters ) ; $ httpUri = new Http ( $ uri ) ; $ httpUri -> setPort ( $ this -> port ) ; $ this -> setUri ( $ httpUri ) ; }
Sets the Request Uri object
13,334
public function getParametersWithValue ( $ requestValues ) { $ parameters = array ( ) ; foreach ( $ this -> parameters as $ paramKey => $ paramDefaultValue ) { if ( isset ( $ requestValues [ $ paramKey ] ) && ! empty ( $ requestValues [ $ paramKey ] ) ) { $ parameters [ $ paramKey ] = $ requestValues [ $ paramKey ] ; }...
Returns an array of all parameters with a given value
13,335
protected function constructActionUrl ( array $ parameters = array ( ) ) { switch ( $ this -> uriBuildMethod ) { case self :: PLAIN_URL_BUILD_METHOD ; return $ this -> baseUrl ; break ; case self :: ADDS_ON_URL_BUILD_METHOD ; return $ this -> replaceAddsOn ( $ this -> baseUrl , $ parameters ) ; break ; default ; throw ...
Returns the url of the remote api action to be called
13,336
public function getOptions ( ) { $ reflection = new ReflectionObject ( $ this ) ; $ methods = $ reflection -> getMethods ( ReflectionMethod :: IS_PUBLIC ) ; $ options = [ ] ; foreach ( $ methods as $ method ) { if ( $ method -> getNumberOfRequiredParameters ( ) > 0 ) { continue ; } $ name = $ method -> name ; if ( isse...
Get the options
13,337
public function getExpiryAttribute ( ) : Carbon { if ( $ this -> cageExpires !== null ) { return $ this -> cageExpires ; } return $ this -> cageExpires = $ this -> created_at -> addMinutes ( $ this -> getAttributeFromArray ( 'length' ) ) ; }
Get cage expiry time .
13,338
public function getRenderedReasonAttribute ( ) : ? string { if ( $ this -> renderedReason !== null ) { return $ this -> renderedReason ; } if ( $ this -> config -> get ( 'laranixauth.cage.save_rendered' , true ) && ( $ rendered = $ this -> getAttributeFromArray ( 'reason_rendered' ) ) !== null ) { return $ this -> rend...
Get rendered reason
13,339
public function getIpv4Attribute ( ) : ? string { $ ip = $ this -> getAttributeFromArray ( 'user_ipv4' ) ; return $ ip !== null ? long2ip ( $ ip ) : null ; }
Get ip attribute
13,340
public function isExpired ( ) : bool { return $ this -> getExpiryAttribute ( ) -> timestamp < Carbon :: now ( ) -> timestamp && $ this -> length !== 0 && ! $ this -> isRemoved ( ) ; }
Check if cage is expired
13,341
public function setNamespaceRoot ( $ namespaceRoot = '\\' ) { $ namespaceRoot = trim ( $ namespaceRoot , '/\\' ) ; if ( empty ( $ namespaceRoot ) ) { $ this -> namespaceRoot = '\\' ; return true ; } $ this -> namespaceRoot = sprintf ( '\\%s\\' , $ namespaceRoot ) ; return true ; }
Set Namespace Root
13,342
private function typePathInfo ( ) { $ request = Request :: createFromGlobals ( ) ; $ pathInfo = $ request -> getPathInfo ( ) ; $ urlArray = explode ( '/' , $ pathInfo ) ; $ controllerName = 'index' ; if ( ! empty ( $ urlArray [ 1 ] ) ) { $ controllerName = $ urlArray [ 1 ] ; } $ controllerName = ucfirst ( strtolower ( ...
Type Path Info
13,343
public function loadUser ( string $ username ) : ? UserInterface { if ( ! isset ( $ this -> cache [ $ username ] ) ) { $ this -> cache [ $ username ] = $ this -> user_provider -> loadUserByUsername ( $ username ) ; } return $ this -> cache [ $ username ] ? : null ; }
Load a user using available user provider .
13,344
protected function findModelTranslation ( $ id , $ languageId ) { $ model = ProductAvailabilityTranslation :: find ( ) -> where ( [ 'availability_id' => $ id , 'language_id' => $ languageId ] ) -> one ( ) ; if ( $ model !== null ) { return $ model ; } else { return false ; } }
Finds the DeliveryMethodTranslation model based on delivery method id and language id . If the model is not found a 404 HTTP exception will be thrown .
13,345
public function create ( string $ rootPath , string $ configFilePath ) : ConfigBagInterface { $ file = $ this -> resolvePath ( $ rootPath , $ configFilePath ) ; $ envs = $ this -> parseMainFile ( $ file ) ; $ envs = $ this -> mergeExternalFiles ( $ file , $ envs ) ; return ConfigBag :: root ( $ envs , $ this -> getEnvi...
Create a ConfigBag .
13,346
protected function resolvePath ( string $ rootPath , string $ configFilePath ) : string { $ file = Path :: makeAbsolute ( $ configFilePath , $ rootPath ) ; if ( ! file_exists ( $ file ) ) { throw new ConfigException ( "Config file doesn't exist." ) ; } return $ file ; }
Resolve config file path and ensure it exists .
13,347
protected function parseMainFile ( string $ file ) : MutableBag { $ envs = $ this -> parse ( $ file ) ; if ( ! $ envs -> has ( 'default' ) ) { $ envs [ 'default' ] = new MutableBag ( ) ; } $ envs = $ this -> sortEnvs ( $ envs ) ; foreach ( $ envs as $ name => $ config ) { if ( $ name === 'default' ) { continue ; } $ pa...
Parse main config file .
13,348
protected function mergeExternalFiles ( string $ file , MutableBag $ envs ) : MutableBag { $ extPos = strrpos ( $ file , '.' ) ; $ pathTemplate = substr_replace ( $ file , '.%s.' , $ extPos , 1 ) ; foreach ( $ envs as $ name => $ config ) { $ envFile = sprintf ( $ pathTemplate , $ name ) ; if ( ! is_readable ( $ envFil...
Merge in separate environment specific files .
13,349
private function sortEnvs ( MutableBag $ envs ) : MutableBag { $ resolver = DependencyResolver :: fromMap ( $ envs , function ( MutableBag $ env , $ key ) { if ( $ key === 'default' ) { return [ ] ; } $ parent = $ env -> get ( '_extends' , 'default' ) ; return [ $ parent ] ; } ) ; try { return $ resolver -> sort ( ) ->...
Sort envs based on their _extends key .
13,350
public function create ( $ appUserId , CardPayment $ cardPayment ) { $ url = sprintf ( 'users/%s/payins/cardpayments/' , $ appUserId ) ; return $ this -> createObject ( $ url , $ cardPayment ) ; }
Create new card payment
13,351
protected function getPermission ( ) { $ label = ucwords ( $ this -> ask ( 'Specify the display name for a new permission' ) ) ; $ name = null ; while ( is_null ( $ name ) ) { $ name = $ this -> ask ( 'What should the key name be set to?' , Str :: slug ( $ label ) ) ; if ( $ this -> confirm ( "Your permission will be a...
Allow the user to specify any number of permissions to add to the database .
13,352
private function generateSeeder ( ) { $ stub = $ this -> files -> get ( __DIR__ . '/stubs/Seeder.stub' ) ; $ permissions = $ this -> permissions -> map ( function ( $ permission ) { return ( array ) $ permission ; } ) ; $ permissions = $ this -> export ( $ permissions -> toArray ( ) , "\t" ) ; $ patterns = [ '__NAME__'...
Create the seeder file so the permissions can be easily added to other environments .
13,353
public function getClassAnnotation ( $ name , $ default = false ) { $ value = $ default ; if ( $ this -> classAnnotations === null ) { $ this -> classAnnotations = $ this -> parse ( ( string ) $ this -> getDocComment ( ) ) ; } if ( isset ( $ this -> classAnnotations [ $ name ] ) ) { $ value = $ this -> classAnnotations...
Get annotation value from class doc . block
13,354
public function getMethodAnnotation ( $ method , $ name , $ default = false ) { $ value = $ default ; if ( isset ( $ this -> methodAnnotations [ $ method ] ) === false ) { $ this -> methodAnnotations [ $ method ] = $ this -> parse ( ( string ) $ this -> getMethod ( $ method ) -> getDocComment ( ) ) ; } if ( isset ( $ t...
Get annotation value from method doc . block
13,355
private function parse ( string $ data ) : array { $ registers = [ 'a' => [ ] , 'd' => false , 'di' => 0 , 'def' => [ 0 => '' , 1 => '' ] ] ; for ( $ i = 0 ; $ i < strlen ( $ data ) ; $ i ++ ) { if ( $ data [ $ i ] === '@' ) { $ registers [ 'd' ] = true ; } elseif ( $ registers [ 'd' ] === true ) { $ this -> parseChara...
Parse doc . block annotations into array
13,356
public function uniqueForEntity ( $ attribute , $ params ) { $ translationsIds = ProductTranslation :: find ( ) -> asArray ( ) -> where ( [ 'product_id' => $ this -> product_id ] ) -> select ( 'id' ) -> all ( ) ; $ seoUrl = SeoData :: find ( ) -> where ( [ 'entity_name' => ProductTranslation :: className ( ) , 'seo_url...
Validation rule which checks if such seo url is already exist in current entity
13,357
public static function receiveMessages ( int $ from_user_id , int $ to_user_id = USER_ID ) : array { $ message_collection = new UsersMessageEntityRepository ( ) ; $ messages = $ message_collection -> setWhereFromUserId ( $ from_user_id ) -> setWhereToUserId ( $ to_user_id ) -> getAsArrayOfObjects ( ) ; $ message_collec...
Notification using browser API Get array of UserMessage
13,358
public static function sendGreenAlert ( string $ text , int $ to_user_id = USER_ID , int $ from_user_id = 0 ) : UsersMessageEntity { return self :: sendMessage ( $ text , $ to_user_id , $ from_user_id , self :: TOASTR_MESSAGE_COLOR_GREEN ) ; }
Notification using green toastr alerts
13,359
public static function sendRedAlert ( string $ text , int $ to_user_id = USER_ID , int $ from_user_id = 0 ) : UsersMessageEntity { return self :: sendMessage ( $ text , $ to_user_id , $ from_user_id , self :: TOASTR_MESSAGE_COLOR_RED ) ; }
Notification using red toastr alerts
13,360
public static function sendBlackAlert ( string $ text , int $ to_user_id = USER_ID , int $ from_user_id = 0 ) : UsersMessageEntity { return self :: sendMessage ( $ text , $ to_user_id , $ from_user_id , self :: TOASTR_MESSAGE_COLOR_BLACK ) ; }
Notification using black toastr alerts
13,361
public static function to ( $ str , $ upperCaseFirst = true ) { $ str = strtr ( ucwords ( strtr ( $ str , [ '_' => ' ' , '.' => '_ ' , '\\' => '_ ' ] ) ) , [ ' ' => '' ] ) ; if ( $ upperCaseFirst === false ) { $ str = lcfirst ( $ str ) ; } return $ str ; }
Converts a string from underscore to camel - case notation
13,362
public static function lookup ( $ payload , $ apiContext = null , $ soapCall = null ) { $ methodName = 'getLookupTransaction' ; $ json = self :: executeCall ( $ methodName , $ payload , null , $ apiContext , $ soapCall ) ; $ ret = new self ( ) ; $ ret -> fromJson ( $ json ) ; return $ ret ; }
Shows details for a payment by ID .
13,363
protected function getParametersFile ( ) { $ file_name = $ this -> appDir . '/config/' . self :: PARAMETERS_FILE . '.php' ; if ( ! file_exists ( $ file_name ) ) { return [ ] ; } if ( null === $ this -> parameters ) { foreach ( require ( $ file_name ) as $ k => $ v ) { $ this -> parameters [ "%{$k}%" ] = $ v ; } } retur...
Return all parameters values
13,364
public function getConfigFile ( ) { $ configPath = $ this -> appDir . '/config/' . self :: CONFIG_FILE . '.php' ; if ( ! file_exists ( $ configPath ) ) { $ configPath = VENDOR_KNOB_BASE_DIR . '/src/config/' . self :: CONFIG_FILE . '.php' ; } if ( null === $ this -> config && file_exists ( $ configPath ) ) { $ this -> c...
Return all global config values
13,365
public static function getAttachmentIdFromUrl ( $ attachmentUrl = '' ) { if ( empty ( $ attachmentUrl ) ) { return ; } global $ wpdb ; $ attachmentId = false ; $ upload_dir_paths = wp_upload_dir ( ) ; if ( false !== strpos ( $ attachmentUrl , $ upload_dir_paths [ 'baseurl' ] ) ) { $ attachmentUrl = preg_replace ( '/-\d...
Return the attachment ID from his url
13,366
public function addMatcher ( UrlMatcherInterface $ matcher ) { $ this -> debug ( sprintf ( 'addMatcher: Adding matcher %s' , get_class ( $ matcher ) ) ) ; $ this -> matchers -> push ( $ matcher ) ; return ( $ this ) ; }
addMatcher Add a new matcher to the stack .
13,367
public function matchRequest ( Request $ request ) { $ context = new RequestContext ( ) ; $ context -> fromRequest ( $ request ) ; $ this -> setContext ( $ context ) ; return ( $ this -> match ( $ request -> getPathInfo ( ) ) ) ; }
matchRequest Match a Request object to a set of routes .
13,368
public function setContext ( RequestContext $ context ) { foreach ( $ this -> matchers as $ matcher ) { $ matcher -> setContext ( $ context ) ; } $ this -> context = $ context ; }
setContext Sets the request context .
13,369
protected function setUrls ( array $ urls ) { foreach ( $ urls as $ key => $ value ) $ this -> urls [ $ key ] = $ value ; }
Sets links to be visited
13,370
protected function validateConnection ( ) : bool { if ( curl_exec ( $ this -> curlHandle ) ) return TRUE ; $ this -> error = "An error has occurred: " . curl_error ( $ this -> curlHandle ) ; return FALSE ; }
Validates the connection .
13,371
protected function validateResult ( $ result ) : bool { if ( ! is_string ( $ result ) ) return TRUE ; if ( stripos ( $ result , "An error" ) !== 0 ) return TRUE ; $ this -> error = $ result ; return FALSE ; }
Validates the result from a session
13,372
protected function setPostFields ( array $ fields ) { foreach ( $ fields as $ key => $ value ) $ this -> fields [ $ key ] = $ value ; }
Sets post data to be sent Expects an associative array
13,373
protected function generatePostFields ( ) : string { $ fieldsString = '' ; foreach ( $ this -> fields as $ key => $ value ) $ fieldsString .= $ key . '=' . $ value . '&' ; return rtrim ( $ fieldsString , '&' ) ; }
Generate the post fields to be sent
13,374
protected function setDefaultOptions ( string $ cookieLocation = '' ) { $ cookie = $ cookieLocation . "cookie.txt" ; curl_setopt ( $ this -> curlHandle , CURLOPT_RETURNTRANSFER , TRUE ) ; curl_setopt ( $ this -> curlHandle , CURLOPT_FOLLOWLOCATION , TRUE ) ; curl_setopt ( $ this -> curlHandle , CURLOPT_COOKIESESSION , ...
Set default curl configurations
13,375
public function addMenu ( $ key , $ description ) { $ description = empty ( $ description ) ? $ key : $ description ; register_nav_menu ( $ key , $ description ) ; }
Register sidebar to WP .
13,376
public function boot ( ) { if ( ! $ this -> booted ) { $ this -> initializeContainer ( ) ; $ this -> initializeBundles ( ) ; $ this -> initializeRouting ( ) ; $ this -> initializeConfigure ( ) ; $ this -> booted = true ; } }
Bootstrap application . Loading cache bundles configuration router and other .
13,377
public function initializeContainer ( ) { $ this -> container = new Container ( [ 'kernel.database' => Fdb :: class , 'kernel.config' => Config :: class , 'kernel.storage' => Storage :: class , 'kernel.routing' => '\\Routes::getRouter' , 'kernel.debug' => Debug :: enable ( $ this -> isDebug ( ) ) , ] ) ; $ this -> cont...
Initialize application container .
13,378
public function initializeBundles ( ) { $ config = $ this -> getContainer ( ) -> singleton ( 'kernel.config' ) ; $ routing = $ this -> getContainer ( ) -> singleton ( 'kernel.routing' ) ; $ this -> bundles = $ this -> registerBundles ( ) ; foreach ( $ this -> bundles as $ bundle ) { $ bundle -> setContainer ( $ this ->...
Initialize application register bundles .
13,379
public function initializeConfigure ( ) { $ config = $ this -> container -> singleton ( 'kernel.config' ) ; $ config -> setVariable ( [ 'root.path' => $ this -> getRootPath ( ) , 'env' => $ this -> getEnvironment ( ) , 'debug' => $ this -> isDebug ( ) , 'version' => AppKernel :: VERSION , ] ) ; $ this -> registerConfig...
Initialize application configuration .
13,380
public function getRootPath ( ) { if ( null === $ this -> rootPath ) { $ this -> rootPath = dirname ( ( new \ ReflectionClass ( $ this ) ) -> getFileName ( ) ) ; } return $ this -> rootPath ; }
Get application work space directory .
13,381
private function addBinFile ( $ phar ) { $ content = file_get_contents ( __DIR__ . '/../../bin/ctb' ) ; $ content = preg_replace ( '{^#!/usr/bin/env php\s*}' , '' , $ content ) ; $ phar -> addFromString ( 'bin/ctb' , $ content ) ; }
Add the binary file .
13,382
private function getStub ( ) { $ stub = <<<'EOF'#!/usr/bin/env php<?php/* * This file is part of ctb. * * For the full copyright and license information, please view * the license that is located at the bottom of this file. */Phar::mapPhar('ctb.phar');EOF ; if ( preg_match ( '{^[a-f0-9]+$}' , $ this -> version ) ) { $...
Build the stub for the phar .
13,383
public function sendEmail ( OrderEvent $ event ) { $ order = $ event -> getOrder ( ) ; $ virtualProductCount = OrderProductQuery :: create ( ) -> filterByOrderId ( $ order -> getId ( ) ) -> filterByVirtual ( true ) -> filterByVirtualDocument ( null , Criteria :: NOT_EQUAL ) -> count ( ) ; if ( $ virtualProductCount > 0...
Send email to notify customer that files for virtual products are available
13,384
protected function fetchTaxonomies ( ) { $ response = $ this -> api -> appData ( ) ; $ taxonomies = array_get ( $ response , 'data.taxonomies' , [ ] ) ; $ this -> taxonomies = new Collection ( $ taxonomies ) ; }
Patch a collection of jobs
13,385
public function taxonomy ( string $ taxonomy ) : Repository { $ taxonomyArr = $ this -> taxonomies -> get ( $ taxonomy ) ; $ this -> taxonomies = new Collection ( $ taxonomyArr ) ; return $ this ; }
Set the working taxonomy
13,386
public function isLogged ( ) { return $ this -> get ( 'security.token_storage' ) -> getToken ( ) && $ this -> get ( 'security.token_storage' ) -> getToken ( ) -> isAuthenticated ( ) && is_object ( $ this -> getUser ( ) ) ; }
Indicates if the user is logged or not .
13,387
public function logUser ( \ Symfony \ Component \ Security \ Core \ User \ UserInterface $ user ) { $ token = new UsernamePasswordToken ( $ user , null , 'main' , $ user -> getRoles ( ) ) ; $ this -> get ( 'security.token_storage' ) -> setToken ( $ token ) ; $ this -> get ( 'event_dispatcher' ) -> dispatch ( Authentica...
Log user correctly .
13,388
private function getDatabaseInstance ( $ id = null ) { $ config = App :: getOption ( 'db' ) ; $ Database = 'Josantonius\\Database\\Database' ; if ( ! class_exists ( $ Database ) || ! is_array ( $ config ) ) { return ; } $ id = $ id ? : array_keys ( $ config ) [ 0 ] ; $ required = [ 'provider' , 'host' , 'user' , 'name'...
Get Database connection .
13,389
public static function renderPagination ( int $ page , int $ per_page , int $ total_products , int $ total_found_products_with_filters , array $ filters = [ ] ) : string { unset ( $ filters [ 'page' ] ) ; $ url = http_build_query ( $ filters ) ; $ pages = ceil ( $ total_found_products_with_filters / $ per_page ) ; $ st...
Pagination copy and modify where you need it - do not use this method originally as it may change use only copied
13,390
private function parseHeaders ( $ headers ) { $ headers_temp = array ( ) ; $ requests = explode ( "\r\n\r\n" , $ headers ) ; for ( $ index = 0 ; $ index < count ( $ requests ) - 1 ; $ index ++ ) { foreach ( explode ( "\r\n" , $ requests [ $ index ] ) as $ i => $ line ) { if ( $ i === 0 ) continue ; list ( $ key , $ val...
Parses headers to an array
13,391
private function parseBody ( $ response , $ httpCode ) { if ( ! is_string ( $ response ) ) { return ; } $ parsed = json_decode ( $ response , 1 ) ; if ( json_last_error ( ) !== 0 ) { throw new MonetivoException ( 'API response is malformed: ' . json_last_error_msg ( ) , 0 , $ httpCode , $ response ) ; } $ this -> body ...
Parses the response to an array
13,392
public function AddOverload ( \ Peg \ Lib \ Definitions \ Element \ Overload $ overload ) { $ overload -> function = & $ this ; $ this -> overloads [ ] = $ overload ; return $ this ; }
Adds a new overload for the function .
13,393
public function authenticate ( GenericUserInterface $ user , $ credential ) { $ userAttributes = $ user -> getAttributes ( ) ; if ( empty ( $ userAttributes ) ) { throw new IdentityNotFoundException ( ) ; } $ this -> store ( $ user -> getAttributes ( ) ) ; return true ; }
Authenticates user with identity
13,394
public function renderGluggiComponent ( string $ type , string $ name , array $ context = [ ] ) : string { $ component = $ this -> finder -> findComponent ( $ type , $ name ) ; if ( null === $ component ) { throw new UnknownComponentException ( $ name , $ type ) ; } $ context = array_replace ( [ "standalone" => false ,...
Renders a gluggi component
13,395
public function getTemplateName ( string $ type , string $ name ) : string { $ component = $ this -> finder -> findComponent ( $ type , $ name ) ; if ( null === $ component ) { throw new UnknownComponentException ( $ name , $ type ) ; } return $ component -> getImportPath ( ) ; }
Returns the template name
13,396
public function getEnvironment ( $ name ) { return isset ( $ this -> environments [ $ name ] ) ? $ this -> environments [ $ name ] : null ; }
Returns the configuration for a given environment .
13,397
public static function create ( float $ timestamp = null ) : \ DateTime { $ date = static :: format ( $ timestamp ) ; return new \ DateTime ( $ date ) ; }
Create a DateTime instance with microsecond precision
13,398
public static function createImmutable ( float $ timestamp = null ) : \ DateTimeImmutable { $ date = static :: format ( $ timestamp ) ; return new \ DateTimeImmutable ( $ date ) ; }
Create a DateTimeImmutable instance with microsecond precision
13,399
public static function convertTimezone ( $ date , string $ toTimezone , string $ fromTimezone = "UTC" , bool $ immutable = false ) : \ DateTimeInterface { if ( $ date instanceof \ DateTimeInterface ) { $ date = $ date -> format ( self :: FORMAT ) ; } elseif ( ! is_string ( $ date ) ) { throw new \ InvalidArgumentExcept...
Convert a date to another timezone