idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
11,600
public function start ( $ metric , array $ tags = array ( ) , $ sampleRate = AbstractMetric :: DEFAULT_SAMPLE_RATE ) { try { $ this -> timers [ $ metric ] = $ this -> metricFactory -> timer ( $ metric , null , $ tags , $ sampleRate ) ; $ this -> timers [ $ metric ] -> start ( ) ; } catch ( \ Exception $ exception ) { $...
Starts a timer metric
11,601
public function end ( $ metric , array $ tags = array ( ) ) { try { if ( ! isset ( $ this -> timers [ $ metric ] ) ) { throw new \ RuntimeException ( "Timer for metric $metric was not started" ) ; } if ( ! empty ( $ tags ) ) { $ this -> timers [ $ metric ] -> setTags ( array_merge ( $ this -> timers [ $ metric ] -> get...
Ends a previously started timer
11,602
public function event ( $ title , $ text , $ type = Event :: INFO , array $ tags = array ( ) , $ timestamp = null ) { try { $ this -> sendEvent ( $ this -> eventFactory -> event ( $ title , $ text , $ type , $ tags , $ timestamp ) ) ; } catch ( \ Exception $ exception ) { $ this -> logException ( $ exception ) ; } retu...
Sends an event
11,603
public function sendMetric ( AbstractMetric $ metric ) { try { $ this -> metricFactory -> addDefaultTagsToEntity ( $ metric ) ; $ this -> sendMetricThroughSenders ( $ metric ) ; } catch ( \ Exception $ exception ) { $ this -> logException ( $ exception ) ; } return $ this ; }
Sends a metric through all metric senders adding the default tags
11,604
public function sendEvent ( Event $ event ) { try { $ this -> eventFactory -> addDefaultTagsToEntity ( $ event ) ; $ this -> sendEventThroughSenders ( $ event ) ; } catch ( \ Exception $ exception ) { $ this -> logException ( $ exception ) ; } }
Sends an event through all event senders adding the default tags
11,605
protected function sendMetricThroughSenders ( AbstractMetric $ metric ) { foreach ( $ this -> metricSenders as $ sender ) { try { $ sender -> send ( $ metric ) ; } catch ( \ Exception $ exception ) { $ this -> logException ( $ exception ) ; } } }
Sends the metric through all senders
11,606
protected function sendEventThroughSenders ( Event $ event ) { foreach ( $ this -> eventSenders as $ sender ) { try { $ sender -> send ( $ event ) ; } catch ( \ Exception $ exception ) { $ this -> logException ( $ exception ) ; } } return $ this ; }
Sends the event through all senders
11,607
protected function logException ( \ Exception $ exception ) { try { $ this -> logger -> error ( $ exception -> getMessage ( ) , array ( 'exception' => $ exception ) ) ; } catch ( \ Exception $ exception ) { trigger_error ( "Error logging Monitor exception: " . $ exception -> getMessage ( ) ) ; } }
Logs the exception found
11,608
protected function pushToChannel ( Job $ job ) { $ channelName = $ job -> channelName ( ) ? $ job -> channelName ( ) : static :: $ defaultChannel ; $ state = $ this -> channelOrFail ( $ channelName ) -> push ( $ job , $ channelName ) ; $ job -> setState ( $ state ) ; return $ job ; }
Push a job onto an channel .
11,609
final private function loadServices ( ) { $ s = JsonListener :: open ( FEnv :: get ( "framework.config.core.services.file" ) ) ; foreach ( $ s as $ one => $ value ) { array_push ( $ this -> services , array ( "name" => $ one , "content" => $ value ) ) ; } }
Load all service in services . json
11,610
final public function get ( string $ name ) { $ service_selected = null ; foreach ( $ this -> services as $ one => $ val ) { if ( $ val [ 'name' ] === $ name ) { if ( ! in_array ( $ val [ 'content' ] -> status , array ( "enabled" , "disabled" ) ) ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Undef...
Get a service by name
11,611
public function model ( Model $ model , PresentableInterface $ presenter ) { $ object = clone $ presenter ; $ object -> set ( $ model ) ; return $ object ; }
Return an instance of a Model wrapped in a presenter object
11,612
public function collection ( Collection $ collection , PresentableInterface $ presenter ) { foreach ( $ collection as $ key => $ value ) { $ collection -> put ( $ key , $ this -> model ( $ value , $ presenter ) ) ; } return $ collection ; }
Return an instance of a Collection with each value wrapped in a presenter object
11,613
public function paginator ( Paginator $ paginator , PresentableInterface $ presenter ) { $ items = [ ] ; foreach ( $ paginator -> getItems ( ) as $ item ) { $ items [ ] = $ this -> model ( $ item , $ presenter ) ; } $ paginator -> setItems ( $ items ) ; return $ paginator ; }
Return an instance of a Paginator with each value wrapped in a presenter object
11,614
public function parse ( ) { if ( $ this -> input === null ) { throw new LogicException ( 'You must specify an IOInterface for input first.' ) ; } return $ this -> parser -> parse ( $ this -> input -> getContent ( ) ) ; }
Reads in the given log and returns the constructed Log object .
11,615
public function write ( Log $ log ) { if ( $ this -> output === null ) { throw new LogicException ( 'You must specify an IOInterface for output first.' ) ; } $ this -> output -> setContent ( $ this -> renderer -> render ( $ log ) ) ; }
Writes out the given Log to the chosen output .
11,616
private function scan ( $ directory , $ filename ) { $ filename = strtolower ( $ filename ) ; foreach ( new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ directory ) ) as $ file ) { if ( strtolower ( $ file -> getFilename ( ) ) == $ filename ) { return $ file -> getRealPath ( ) ; } } return null ; ...
Scan a directory for a filename
11,617
public function resourceName ( ) { if ( ! $ this -> _resourceName ) { $ this -> _resourceName = str_replace ( '_' , '-' , $ this -> getTable ( ) ) ; } return $ this -> _resourceName ; }
Return the unique identifier for this object .
11,618
protected function parseConfig ( $ config ) { $ parsed = [ ] ; foreach ( $ config as $ key => $ value ) { if ( $ value instanceof XType ) { $ parsed [ $ key ] = $ value ; continue ; } $ parsed [ $ key ] = $ this -> stringToType ( $ value ) ; } return $ parsed ; }
Parses each array value to a type
11,619
protected function stringToType ( $ config ) { list ( $ typeName , $ properties ) = $ this -> splitTypeAndProperties ( $ config ) ; $ type = $ this -> createType ( $ typeName ) ; if ( $ properties ) { $ type -> fill ( $ this -> parseProperties ( $ properties ) ) ; } if ( ! $ type instanceof ObjectType ) { return $ type...
Creates a type by a string and fills it
11,620
protected function buildKeyProvider ( ObjectType $ type ) { $ keyClass = $ type -> class ; return function ( ) use ( $ keyClass , & $ type ) { $ root = new $ keyClass ( ) ; $ config = $ root -> xTypeConfig ( ) ; return $ this -> parseConfig ( $ config ) ; } ; }
Creates a deferred key provider to avoid loading the complete object on first access
11,621
protected function createType ( $ typeName ) { if ( isset ( $ this -> typeCache [ $ typeName ] ) ) { return clone $ this -> typeCache [ $ typeName ] ; } if ( ! $ this -> hasExtension ( $ typeName ) ) { $ class = $ this -> typeToClassName ( $ typeName ) ; $ this -> typeCache [ $ typeName ] = new $ class ( ) ; return clo...
Creates a type by a name
11,622
protected function parseProperties ( array $ properties ) { $ parsed = [ ] ; foreach ( $ properties as $ propertyString ) { if ( ! mb_strpos ( $ propertyString , ':' ) ) { list ( $ key , $ value ) = $ this -> parseBooleanShortcut ( $ propertyString ) ; $ parsed [ Type :: camelCase ( $ key ) ] = $ value ; continue ; } l...
Parses all property string of an array into single arrays
11,623
protected function splitTypeAndProperties ( $ rule ) { if ( ! mb_strpos ( $ rule , ':[' ) ) { $ parts = explode ( '|' , $ rule ) ; $ typeName = array_shift ( $ parts ) ; return [ $ typeName , $ parts ] ; } $ chars = Helper :: stringSplit ( $ rule ) ; $ level = 0 ; $ isFirst = true ; $ typeName = '' ; $ parts = [ ] ; $ ...
Splits the type name from the properties
11,624
protected function typeToClassName ( $ typeName ) { $ classBase = Type :: studlyCaps ( $ typeName ) . 'Type' ; $ class = __NAMESPACE__ . "\\$classBase" ; if ( class_exists ( $ class ) ) { return $ class ; } $ class = __NAMESPACE__ . "\UnitTypes\\$classBase" ; if ( class_exists ( $ class ) ) { return $ class ; } throw n...
Translate the type name to a class name
11,625
public static function mock ( array $ userData = [ ] ) : self { $ data = \ array_merge ( [ 'SERVER_PROTOCOL' => 'HTTP/1.1' , 'REQUEST_METHOD' => 'GET' , 'SCRIPT_NAME' => '' , 'REQUEST_URI' => '' , 'QUERY_STRING' => '' , 'SERVER_NAME' => 'localhost' , 'SERVER_PORT' => 80 , 'HTTP_HOST' => 'localhost' , 'HTTP_ACCEPT' => '...
Create mock environment
11,626
public function showInfo ( $ view , $ message , $ title = null ) { return $ this -> show ( $ view , 'info' , $ message , $ title ) ; }
Affiche un message de type information .
11,627
public function showWarning ( $ view , $ message , $ title = null ) { return $ this -> show ( $ view , 'warning' , $ message , $ title ) ; }
Affiche un message de type avertissement .
11,628
public function showError ( $ view , $ message , $ title = null ) { return $ this -> show ( $ view , 'error' , $ message , $ title ) ; }
Affiche un message de type erreur .
11,629
protected function findNodeIndex ( Node $ node ) { foreach ( $ this -> data as $ i => $ added ) { if ( $ added -> getId ( ) == $ node -> getId ( ) ) { return $ i ; } } $ nodeHash = spl_object_hash ( $ node ) ; foreach ( $ this -> data as $ i => $ added ) { if ( spl_object_hash ( $ added ) == $ nodeHash ) { return $ i ;...
Try to find the node and returns its index
11,630
protected function getRemovedKeys ( ) { $ removedKeys = [ ] ; foreach ( $ this -> originalAttributes as $ key => $ value ) { if ( ! array_key_exists ( $ key , $ this -> attributes ) ) { $ removedKeys [ ] = $ key ; continue ; } } return $ removedKeys ; }
Return all removed keys . You could set them all to zero in storage .
11,631
protected function addPathIfNeeded ( EloquentNode $ node ) { if ( ! $ this -> pathKey ) { return ; } if ( $ node -> getAttribute ( $ this -> pathKey ) ) { return ; } $ segment = $ node -> getAttribute ( $ this -> segmentKey ) ; if ( $ node -> isRoot ( ) && $ segment ) { $ node -> setAttribute ( $ this -> pathKey , '/' ...
Calculate and add a stored path attribute if a pathKey exists .
11,632
protected function buildAncestorQuery ( $ childId ) { $ grammar = $ this -> select ( ) -> getGrammar ( ) ; $ table = $ this -> model -> getTable ( ) ; $ idKey = $ this -> model -> getKeyName ( ) ; $ idQueryColumn = $ grammar -> wrap ( "$table.$idKey" ) ; $ childQuery = $ this -> select ( [ "$table.$this->parentIdKey" ]...
Build the query to retrieve the parents from database .
11,633
public function getReader ( $ name ) { if ( ! $ this -> hasReader ( $ name ) ) { throw new \ OutOfBoundsException ( sprintf ( 'Undefined reader "%s"' , $ name ) ) ; } return $ this -> readers [ $ name ] ; }
Get event reader
11,634
public function markdown ( string $ markdown , array $ args = [ ] ) : string { if ( ! $ markdown ) { return $ markdown ; } elseif ( ! $ this -> canMarkdown ( ) ) { return $ markdown ; } elseif ( ! $ this -> WPCom_Markdown ) { return $ markdown ; } $ default_args = [ 'unslash' => false ] ; $ args += $ default_args ; ret...
Markdown via Jetpack .
11,635
public function markdownEnabled ( string $ for = '' ) : bool { $ for = $ for === 'posts' || $ for === 'comments' ? $ for : 'posts' ; return $ this -> Wp -> is_jetpack_active && \ Jetpack :: is_module_active ( 'markdown' ) && ( $ for === 'posts' || \ Jetpack :: get_option ( 'wpcom_publish_' . $ for . '_with_markdown' ) ...
Jetpack markdown enabled?
11,636
public function canMarkdown ( ) : bool { if ( ! isset ( $ this -> WPCom_Markdown ) ) { $ this -> WPCom_Markdown = $ this -> Wp -> is_jetpack_active && class_exists ( 'WPCom_Markdown' ) ? \ WPCom_Markdown :: get_instance ( ) : false ; } return ( bool ) $ this -> WPCom_Markdown ; }
Can markdown via Jetpack?
11,637
public static function flattenArray ( array $ array , $ prefix = '' ) { $ prefix = self :: keySanitize ( $ prefix ) ; $ result = [ ] ; foreach ( $ array as $ key => $ val ) { $ key = strtolower ( $ key ) ; if ( is_array ( $ val ) ) { $ result += self :: flattenArray ( $ val , $ prefix . $ key . '.' ) ; continue ; } $ k...
flatten a multi - dimensional array with concatenated keys
11,638
public static function ensureAssociativeArray ( $ object ) { if ( ! is_object ( $ object ) && ! is_array ( $ object ) ) { return $ object ; } $ data = ( array ) $ object ; foreach ( $ data as $ key => $ value ) { $ data [ $ key ] = self :: ensureAssociativeArray ( $ value ) ; } return $ data ; }
Ensure that the given is array or object is an associative array . If not the object will be converted .
11,639
public static function getArrayValueForKeyOrDefault ( array & $ array , string $ key , $ default , bool $ ignoreCase = false , bool $ deepSearchDotNotation = false ) { $ keyToCheck = $ key ; $ arrayToCheck = & $ array ; if ( $ ignoreCase ) { $ keyToCheck = strtolower ( $ keyToCheck ) ; $ arrayToCheck = array_change_key...
Get the value from an array for the given key . Return a default value if the key could not be found .
11,640
public static function doesArrayHaveValue ( array & $ array , $ value , bool $ ignoreCase = false ) : bool { if ( ! is_array ( $ array ) || empty ( $ array ) ) { return false ; } $ valueToCheck = ( $ ignoreCase ) ? strtolower ( $ value ) : $ value ; $ arrayToCheck = ( $ ignoreCase ) ? array_change_key_case ( $ array ) ...
Checks if the given value exists in an array .
11,641
public static function doesArrayHaveValueForKey ( array & $ array , string $ key , bool $ ignoreCase = false , bool $ deepSearchDotNotation = false ) : bool { return ! is_null ( self :: getArrayValueForKeyOrDefault ( $ array , $ key , null , $ ignoreCase , $ deepSearchDotNotation ) ) ; }
Checks if the given key exists in an array .
11,642
public function create ( $ username , $ password , $ email , $ active , $ superadmin ) { $ user = $ this -> userManager -> createUser ( ) ; $ user -> setUsername ( $ username ) ; $ user -> setEmail ( $ email ) ; $ user -> setPlainPassword ( $ password ) ; $ user -> setEnabled ( ( bool ) $ active ) ; $ user -> setSuperA...
Creates a user and returns it .
11,643
public function deactivate ( $ username ) { $ user = $ this -> findUserByUsernameOrThrowException ( $ username ) ; $ user -> setEnabled ( false ) ; $ this -> userManager -> updateUser ( $ user ) ; $ event = new UserEvent ( $ user , $ this -> getRequest ( ) ) ; $ this -> dispatcher -> dispatch ( Events :: USER_DEACTIVAT...
Deactivates the given user .
11,644
public function changePassword ( $ username , $ password ) { $ user = $ this -> findUserByUsernameOrThrowException ( $ username ) ; $ user -> setPlainPassword ( $ password ) ; $ this -> userManager -> updateUser ( $ user ) ; $ event = new UserEvent ( $ user , $ this -> getRequest ( ) ) ; $ this -> dispatcher -> dispatc...
Changes the password for the given user .
11,645
public function promote ( $ username ) { $ user = $ this -> findUserByUsernameOrThrowException ( $ username ) ; $ user -> setSuperAdmin ( true ) ; $ this -> userManager -> updateUser ( $ user ) ; $ event = new UserEvent ( $ user , $ this -> getRequest ( ) ) ; $ this -> dispatcher -> dispatch ( Events :: USER_PROMOTED ,...
Promotes the given user .
11,646
public function demote ( $ username ) { $ user = $ this -> findUserByUsernameOrThrowException ( $ username ) ; $ user -> setSuperAdmin ( false ) ; $ this -> userManager -> updateUser ( $ user ) ; $ event = new UserEvent ( $ user , $ this -> getRequest ( ) ) ; $ this -> dispatcher -> dispatch ( Events :: USER_DEMOTED , ...
Demotes the given user .
11,647
public function addRole ( $ username , $ role ) { $ user = $ this -> findUserByUsernameOrThrowException ( $ username ) ; if ( $ user -> hasRole ( $ role ) ) { return false ; } $ user -> addRole ( $ role ) ; $ this -> userManager -> updateUser ( $ user ) ; return true ; }
Adds role to the given user .
11,648
private function findUserByUsernameOrThrowException ( $ username ) { $ user = $ this -> userManager -> findUserByUsername ( $ username ) ; if ( ! $ user ) { throw new InvalidArgumentException ( sprintf ( 'User identified by "%s" username does not exist.' , $ username ) ) ; } return $ user ; }
Finds a user by his username and throws an exception if we can t find it .
11,649
public function addItem ( Item $ item ) { if ( empty ( $ item -> title ) && empty ( $ item -> description ) ) { throw new Exception ( 'At least one of title or description must be defined.' ) ; } $ this -> items [ ] = $ item ; }
Add feed item
11,650
public function actionEducation ( $ id ) { Url :: remember ( '' , 'actions-redirect' ) ; $ model = $ this -> findModel ( $ id ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ model -> getEducations ( ) , ] ) ; return $ this -> render ( '_education' , [ 'model' => $ model , 'dataProvider' => $ dataProvider ,...
Shows education about user .
11,651
public function actionCareer ( $ id ) { Url :: remember ( '' , 'actions-redirect' ) ; $ model = $ this -> findModel ( $ id ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ model -> getCareers ( ) , ] ) ; return $ this -> render ( '_career' , [ 'model' => $ model , 'dataProvider' => $ dataProvider , ] ) ; }
Shows career about user .
11,652
public function importDeferred ( Asset $ asset ) : bool { $ fileType = $ this -> getFileType ( $ asset ) ; return $ fileType -> importDeferred ( ) ; }
Returns whether the given asset should be imported deferred
11,653
public static function defaultCliErrorRender ( string $ errType , string $ errMsg , string $ errFile , int $ errLine , array $ backtrace , $ exceptionCode ) { if ( ! empty ( $ exceptionCode ) ) { $ errMsg = '#' . $ exceptionCode . ' : ' . $ errMsg ; } $ msgError = $ errType . ' Error : ' . $ errMsg . ' in ' . $ errFile...
The default cli render in BFW
11,654
public static function defaultErrorRender ( string $ errType , string $ errMsg , string $ errFile , int $ errLine , array $ backtrace , $ exceptionCode ) { http_response_code ( 500 ) ; ob_clean ( ) ; if ( ! empty ( $ exceptionCode ) ) { $ errMsg = '#' . $ exceptionCode . ' : ' . $ errMsg ; } echo ' <!doctype htm...
The default error render in BFW
11,655
public function getVar ( string $ specific_ep = '' , $ default = null ) { if ( ! did_action ( 'wp' ) ) { throw new Exception ( '`wp` action not done yet.' ) ; } $ WP = $ GLOBALS [ 'wp' ] ; $ WP_Query = $ GLOBALS [ 'wp_the_query' ] ; if ( ! get_option ( 'permalink_structure' ) ) { return $ default ; } elseif ( empty ( $...
Get endpoint query var .
11,656
public function search ( $ query ) { $ this -> logger -> debug ( 'Category:search:' , [ $ query ] ) ; if ( ! Tools :: isGoodString ( $ query ) ) { $ this -> logger -> error ( 'Category::search: invalid query' ) ; return [ ] ; } $ this -> setGeneratorSearch ( $ query , self :: CATEGORY_NAMESPACE ) ; return $ this -> get...
search for categories
11,657
public function getCategoryfromPage ( ) { $ this -> logger -> debug ( 'Category:getCategoryfromPage' ) ; if ( ! $ this -> setIdentifier ( '' , 's' ) ) { return [ ] ; } $ this -> setGeneratorCategories ( ) ; return $ this -> getCategoryinfoResponse ( ) ; }
get categories from a page
11,658
public function createFromArray ( array $ row ) { $ entities = $ this -> unitOfWork -> getEntityRegistry ( ) -> getEntityBuilder ( ) -> castToEntity ( [ $ row ] , $ this -> className ) ; return array_shift ( $ entities ) ; }
Create a new entity
11,659
public function getMeta ( ) { $ meta = $ this -> unitOfWork -> getEntityRegistry ( ) -> getEntityBuilder ( ) -> getMeta ( $ this -> className ) ; return $ meta ; }
Get the meta data for the entity
11,660
public function bind ( $ entity , array $ data ) { $ meta = $ this -> getMeta ( ) ; foreach ( $ data as $ key => $ value ) { if ( is_null ( $ value ) ) { continue ; } if ( array_key_exists ( $ key , $ meta -> fields ) ) { $ property = $ meta -> propertyName ( $ key ) ; $ entity -> { $ property } = $ value ; } } $ this ...
Change an entities properties
11,661
protected function validateTagToken ( TagToken $ token ) : bool { $ tagName = $ token -> getTagName ( ) ; $ tagDef = $ this -> tagDefs -> get ( $ tagName ) ; if ( ! isset ( $ tagDef ) ) { return false ; } return $ tagDef -> validate ( $ token ) ; }
Checks if tag token is valid against tag definition .
11,662
protected function processRawContentTagTokens ( array $ tokens ) : array { $ rawTagName = null ; return array_reduce ( $ tokens , function ( array $ tokens , $ token ) use ( & $ rawTagName ) { if ( ! isset ( $ rawTagName ) ) { if ( $ token instanceof TagToken ) { $ tagName = $ token -> getTagName ( ) ; $ tagDef = $ thi...
Converts child tags of raw - content tags to a raw text .
11,663
public function tokenize ( string $ text ) : array { $ pattern = '/(\[ \/? \w+ (?: = (?: "[^"]+" |\'[^\']+\' |[^]]+ ) )?\])/x' ; $ flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ; $ tokens = preg_split ( $ pattern , $ text , - 1 , $ flags ) ; $ t...
Converts raw text into the array of tokens .
11,664
public function getForResource ( $ resource ) { $ resourceName = $ this -> resourceName ( $ resource ) ; if ( isset ( $ this -> resourceFactories [ $ resourceName ] ) ) { return $ this -> resourceFactories [ $ resourceName ] ; } throw new HandlerNotFoundException ( "No handler found for resource '$resourceName'" ) ; }
Get the validator factory setted for a resource
11,665
public function setForResource ( $ resource , $ classOrCallableOrInstance ) { $ factory = $ classOrCallableOrInstance ; $ resourceName = $ this -> resourceName ( $ resource ) ; if ( $ factory instanceof ValidatorContract ) { $ this -> resourceFactories [ $ resourceName ] = function ( ) use ( $ factory ) { return clone ...
Set a custom validator for one resource name . The assigned validator is used for the resource instead of all others in the chain .
11,666
public function html ( $ plain , $ nice = false ) { $ paragraphs = explode ( "\n\n" , trim ( $ plain ) ) ; $ html = '' ; if ( count ( $ paragraphs ) == 1 ) { return nl2br ( trim ( $ paragraphs [ 0 ] ) ) ; } foreach ( $ paragraphs as $ paragraph ) { $ html .= '<p>' . nl2br ( trim ( $ paragraph ) ) . '</p>' ; } return $ ...
Converts plain to html text .
11,667
public function date ( $ date , $ format = null ) { if ( $ this -> isEmptyDate ( $ date ) ) { return '' ; } $ isLocalizerFormat = in_array ( $ format , [ Localizer :: SHORT , Localizer :: LONG , Localizer :: VERBOSE ] ) ; if ( $ format && ! $ isLocalizerFormat ) { return $ this -> toDateTime ( $ date ) -> format ( $ fo...
Format a date .
11,668
public function number ( $ number , $ decimals = 0 ) { if ( ! $ this -> localizer ) { return number_format ( $ number , $ decimals ) ; } return $ this -> localizer -> number ( $ number , $ decimals ) ; }
Display a nice number .
11,669
public function idBySlug ( string $ slug , bool $ no_cache = false ) : int { static $ product_ids ; if ( ! ( $ slug = ( string ) $ slug ) ) { return 0 ; } elseif ( isset ( $ product_ids [ $ slug ] ) ) { return $ product_ids [ $ slug ] ; } elseif ( ( string ) ( int ) $ slug === $ slug ) { return $ product_ids [ $ slug ]...
Product ID by slug .
11,670
public function bySlug ( string $ slug , bool $ no_cache = false ) { $ slug = ( string ) $ slug ; if ( ! ( $ slug = ( string ) $ slug ) ) { return null ; } elseif ( ! ( $ product_id = $ this -> idBySlug ( $ slug , $ no_cache ) ) ) { return null ; } elseif ( ! ( $ WC_Product = wc_get_product ( $ product_id ) ) ) { retur...
Product by slug .
11,671
public function post ( \ WC_Product $ WC_Product ) { if ( ! $ WC_Product -> exists ( ) ) { return null ; } if ( $ WC_Product -> is_type ( 'variation' ) ) { $ WP_Post = get_post ( $ WC_Product -> get_parent_id ( ) ) ; } else { $ WP_Post = get_post ( $ WC_Product -> get_id ( ) ) ; } return $ WP_Post instanceof \ WP_Post ...
Product post .
11,672
public function parent ( \ WC_Product $ WC_Product ) { if ( ! $ WC_Product -> exists ( ) ) { return null ; } if ( $ WC_Product -> is_type ( 'variation' ) ) { $ WC_Parent_Product = wc_get_product ( $ WC_Product -> get_parent_id ( ) ) ; } else { $ WC_Parent_Product = null ; } return $ WC_Parent_Product instanceof \ WC_Pr...
Product parent .
11,673
public function addAllHandlers ( string $ configKeyName = 'handlers' , string $ configFileName = 'monolog.php' ) { $ handlers = $ this -> config -> getValue ( $ configKeyName , $ configFileName ) ; if ( ! is_array ( $ handlers ) ) { throw new Exception ( 'Handlers list into monolog config file should be an array.' , se...
Adding all handlers to monolog logger
11,674
public function addNewHandler ( array $ handlerInfos ) { $ this -> checkHandlerInfos ( $ handlerInfos ) ; $ handlerClassName = $ handlerInfos [ 'name' ] ; $ handler = new $ handlerClassName ( ... $ handlerInfos [ 'args' ] ) ; $ this -> handlers [ ] = $ handler ; $ this -> logger -> pushHandler ( $ handler ) ; }
Check and add a new handler to the logger
11,675
protected function checkHandlerName ( array $ handlerInfos ) { if ( ! array_key_exists ( 'name' , $ handlerInfos ) ) { throw new Exception ( 'The handler infos should have the property name' , self :: ERR_HANDLER_INFOS_MISSING_NAME ) ; } if ( ! is_string ( $ handlerInfos [ 'name' ] ) ) { throw new Exception ( 'The hand...
Check the handler name
11,676
public function getHash ( ) { $ data = $ this -> getData ( ) ; if ( is_object ( $ data ) ) { if ( method_exists ( $ data , 'getHash' ) ) { return $ data -> getHash ( ) ; } else { return sha1 ( serialize ( $ data ) ) ; } } if ( is_string ( $ data ) ) { return sha1 ( $ data ) ; } throw new LogicException ( "Cant get hash...
Returns a sha1 hash of the content
11,677
public function deployerActivity ( ) { $ configs = JsonListener :: open ( FEnv :: get ( "framework.config.core.config.file" ) ) ; return ( $ this -> render ( "deployermanager" , array ( "selected" => "deployermanager" , "default_env" => $ configs -> default_env , "loader_msg" => "Deployer Manager" ) ) ) ; }
Going to deployer manager
11,678
public function transform ( string $ markdown , int $ post_id = 0 , array $ args = [ ] ) : string { global $ wp_markdown_extra ; $ mde = $ wp_markdown_extra ; if ( ! $ markdown ) { return $ markdown ; } elseif ( ! $ this -> canTransform ( ) ) { return $ markdown ; } elseif ( ! $ mde ) { return $ markdown ; } return $ m...
Transform via WP MD Extra .
11,679
public function enabled ( string $ for = '' ) : bool { global $ wp_markdown_extra ; $ mde = $ wp_markdown_extra ; $ for = $ for === 'posts' || $ for === 'comments' ? $ for : 'posts' ; return $ mde && $ mde -> s :: getOption ( $ for . '_enable' ) ; }
WP MD Extra enabled?
11,680
protected function resolveOnce ( $ class ) { if ( isset ( $ this -> instances [ $ class ] ) ) { return $ this -> instances [ $ class ] ; } $ this -> instances [ $ class ] = call_user_func ( $ this -> container , $ class ) ; return $ this -> instances [ $ class ] ; }
Resolves the boot class once via the container .
11,681
protected function callIfExists ( $ booter , $ method ) { if ( method_exists ( $ booter , $ method ) ) { $ this -> container -> call ( [ $ booter , $ method ] , [ $ this -> container ] ) ; } }
Calls the booter method if exists .
11,682
protected function callConfiguratorsOnce ( ) { if ( $ this -> configuratorsCalled ) { return ; } foreach ( static :: $ configurators as $ listener ) { call_user_func ( $ listener , $ this , $ this -> container ) ; } $ this -> configuratorsCalled = true ; }
Calls the creation listeners .
11,683
public function getAsLabel ( ) { $ key = substr ( $ this -> key , strpos ( $ this -> key , '.' ) + 1 ) ; $ label = str_replace ( '.' , ' ' , $ key ) ; return ucfirst ( $ label ) ; }
Get suggestion for a label based on the key
11,684
protected function lastOkTime ( int $ time = null ) : int { return ( int ) $ this -> s :: sysOption ( 'dependencies_last_ok_time' , $ time ) ; }
Last OK time .
11,685
protected function archiveUrl ( string $ slug , string $ type , string $ version = '' ) : string { switch ( $ type ) { case 'plugin' : if ( $ version ) { return 'https://downloads.wordpress.org/plugin/' . urlencode ( $ slug ) . '.' . urlencode ( $ version ) . '.zip' ; } return 'https://wordpress.org/plugins/' . urlenco...
URL to dependency archive .
11,686
public function get ( $ key = null , $ default = null ) { if ( is_null ( $ key ) ) { return $ this -> elements ; } if ( $ this -> exists ( $ this -> elements , $ key ) ) { return $ this -> elements [ $ key ] ; } if ( strpos ( $ key , '.' ) === false ) { return $ default ; } $ items = $ this -> elements ; foreach ( expl...
Return the value of a given key
11,687
public function has ( $ keys ) { $ keys = ( array ) $ keys ; if ( ! $ this -> elements || $ keys === [ ] ) { return false ; } foreach ( $ keys as $ key ) { $ items = $ this -> elements ; if ( $ this -> exists ( $ items , $ key ) ) { continue ; } foreach ( explode ( '.' , $ key ) as $ segment ) { if ( ! is_array ( $ ite...
Check if a given key or keys exists
11,688
public function isEmpty ( $ keys = null ) { if ( is_null ( $ keys ) ) { return empty ( $ this -> elements ) ; } $ keys = ( array ) $ keys ; foreach ( $ keys as $ key ) { if ( ! empty ( $ this -> get ( $ key ) ) ) { return false ; } } return true ; }
Check if a given key or keys are empty
11,689
public function merge ( $ key , $ value = null ) { if ( is_array ( $ key ) ) { $ this -> elements = array_merge ( $ this -> elements , $ key ) ; } elseif ( is_string ( $ key ) ) { $ items = ( array ) $ this -> get ( $ key ) ; $ value = array_merge ( $ items , $ this -> getArrayItems ( $ value ) ) ; $ this -> set ( $ ke...
Merge a given array or a Dot object with the given key or with the whole Dot object
11,690
public function toJson ( $ key = null , $ options = 0 ) { if ( is_string ( $ key ) ) { return json_encode ( $ this -> get ( $ key ) , $ options ) ; } $ options = $ key === null ? 0 : $ key ; return json_encode ( $ this -> elements , $ options ) ; }
Return the value of a given key or all the values as JSON
11,691
public function addModule ( string $ moduleName ) { $ this -> modules [ $ moduleName ] = new \ BFW \ Module ( $ moduleName ) ; $ this -> modules [ $ moduleName ] -> loadModule ( ) ; }
Add a module to the modules s list And instantiate \ BFW \ Module for this module
11,692
public function getModuleByName ( string $ moduleName ) : \ BFW \ Module { if ( $ this -> hasModule ( $ moduleName ) === false ) { throw new Exception ( 'The Module ' . $ moduleName . ' has not been found.' , $ this :: ERR_NOT_FOUND ) ; } return $ this -> modules [ $ moduleName ] ; }
Get the \ BFW \ Module instance for a module
11,693
public function readNeedMeDependencies ( ) { foreach ( $ this -> modules as $ readModuleName => $ module ) { $ loadInfos = $ module -> getLoadInfos ( ) ; if ( ! property_exists ( $ loadInfos , 'needMe' ) ) { continue ; } $ needMe = ( array ) $ loadInfos -> needMe ; foreach ( $ needMe as $ needModuleName ) { if ( ! isse...
Read the needMe property for each module and add the dependency
11,694
public function generateTree ( ) { $ tree = new \ bultonFr \ DependencyTree \ DependencyTree ; foreach ( $ this -> modules as $ moduleName => $ module ) { $ priority = 0 ; $ depends = [ ] ; $ loadInfos = $ module -> getLoadInfos ( ) ; if ( property_exists ( $ loadInfos , 'priority' ) ) { $ priority = ( int ) $ loadInfo...
Generate the dependency tree for all declared module
11,695
public static function resetAll ( ) { static :: $ from = null ; static :: $ color = null ; static :: $ token = null ; static :: $ auth = null ; static :: $ client = null ; static :: $ roomAPI = null ; static :: $ message = null ; }
Reset all configuration
11,696
public static function message ( $ token , $ room , $ msg , $ from = null , $ color = null ) { if ( ! empty ( $ token ) ) { static :: setToken ( $ token ) ; } static :: setMessage ( $ msg , $ from , $ color ) ; $ roomAPI = static :: getRoomAPI ( ) ; $ message = static :: getMessage ( ) ; $ roomAPI -> sendRoomNotificati...
Send room notification
11,697
public function run ( Application $ application ) : void { if ( $ this -> engineState !== 'idle' ) { throw new InvalidEngineStateException ( 'Engine::run() MUST NOT be called while already running.' ) ; } Loop :: setErrorHandler ( function ( \ Throwable $ error ) use ( $ application ) { $ application -> exceptionHandle...
Ensures that the appropriate plugins are booted and then executes the application .
11,698
protected function retrieveByPrimaryKey ( array $ primary_key_values ) { $ entity = parent :: retrieveByPrimaryKey ( $ primary_key_values ) ; if ( $ entity ) { $ entity -> definition = $ this -> definition ; } return $ entity ; }
Load saved entity data and create new object .
11,699
public function slug ( string $ basename ) : string { if ( ( $ slug = mb_strstr ( $ basename , '/' , true ) ) ) { return $ slug ; } elseif ( ( $ slug = mb_strstr ( $ basename , '.php' , true ) ) ) { return $ slug ; } return '' ; }
Plugin slug from basename .