idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
8,000
public static function pascalCase ( string $ value ) : string { $ value = ucwords ( str_replace ( [ '-' , '_' ] , ' ' , $ value ) ) ; return str_replace ( ' ' , '' , $ value ) ; }
Pascal case .
8,001
public static function snakeCase ( string $ value , bool $ toLowerCase = false , string $ separator = '_' ) : string { $ replace = strtolower ( preg_replace ( [ '/\s+/' , '/\s/' , '/(?|([a-z\d])([A-Z])|([^\^])([A-Z][a-z]))/' , '/[-_]+/' ] , [ ' ' , $ separator , '$1' . $ separator . '$2' , $ separator ] , trim ( $ valu...
Snake case .
8,002
public static function kebabCase ( string $ value , bool $ toLowerCase = true ) : string { return static :: snakeCase ( $ value , $ toLowerCase , '-' ) ; }
Kebab case .
8,003
public static function caseConvertArrayKeysRecursively ( array $ array , string $ method = self :: PASCALCASE , string $ separator = '_' ) : array { $ return = [ ] ; foreach ( $ array as $ key => $ value ) { if ( ! preg_match ( '/^\d+$/' , $ key ) ) { $ key = self :: $ method ( preg_replace ( '/\-/' , '_' , $ key ) , t...
Convert key case Recursively using the method defined .
8,004
public static function indexOf ( string $ haystack , string $ needle , int $ offset = 0 ) : int { $ pos = self :: strpos ( $ haystack , $ needle , $ offset ) ; return is_int ( $ pos ) ? $ pos : - 1 ; }
Index of .
8,005
public static function fire ( $ code ) { if ( $ code == 0 ) { return new LogicException ( 'Error code 0 means upload was successful' ) ; } if ( ! in_array ( $ code , array_keys ( self :: $ messages ) ) ) { return new self ( self :: $ default , self :: UPPLOAD_ERR_DEFAULT ) ; } return new self ( self :: $ messages [ $ c...
Throws new FileUploadException with message and code based on passed code
8,006
public static function getAllSettings ( ) { $ settings = Settings :: all ( ) ; $ settingsList = [ ] ; foreach ( $ settings as $ setting ) { $ settingsList [ $ setting -> settingsKey ] = $ setting -> value ; } return $ settingsList ; }
Get all settings as a list
8,007
public static function getSetting ( $ key ) { $ setting = Settings :: all ( ) -> where ( 'settingsKey' , $ key ) -> first ( ) ; if ( $ setting ) { return $ setting -> value ; } return ; }
Get a setting
8,008
public function getLeads ( $ startDate , $ endDate , array $ params = array ( ) ) { $ isValidStartDate = $ this -> utils -> isSystemDatetime ( $ startDate ) ; $ isValidEndDate = $ this -> utils -> isSystemDatetime ( $ endDate ) ; if ( ! $ isValidEndDate || ! $ isValidStartDate ) { throw new InvalidArgumentException ( '...
Get leads from specific period
8,009
public function setArray ( array $ data , bool $ doMerge = false ) : self { if ( $ doMerge ) { foreach ( $ data as $ key => $ value ) { $ this -> data [ $ key ] = $ value ; } } else { $ this -> data = $ data ; } return $ this ; }
Set array .
8,010
public function setInt ( string $ key , int $ value ) : self { $ this -> set ( $ key , intval ( $ value ) ) ; return $ this ; }
Set int .
8,011
public function setBool ( string $ key , $ value ) { if ( is_string ( $ value ) ) { $ value = strtolower ( $ value ) ; } $ this -> set ( $ key , in_array ( $ value , [ 1 , true , '1' , 'true' , 'yes' , 'on' ] , true ) ) ; return $ this ; }
Set bool .
8,012
protected function handleException ( EditorExceptionInterface $ exception ) { if ( $ this -> getParameter ( 'kernel.debug' ) ) { throw $ exception ; } return $ this -> buildResponse ( [ 'error' => $ exception -> getMessage ( ) , ] ) ; }
Handles editor exception .
8,013
protected function persist ( $ entity ) { $ manager = $ this -> getDoctrine ( ) -> getManager ( ) ; $ manager -> persist ( $ entity ) ; $ manager -> flush ( ) ; }
Persists the entity and flush the entity manager .
8,014
protected function validate ( $ object ) { $ errorList = $ this -> get ( 'validator' ) -> validate ( $ object ) ; if ( 0 < $ errorList -> count ( ) ) { $ message = 'Row validation failed.' ; if ( $ this -> getParameter ( 'kernel.debug' ) ) { $ messages = [ ] ; foreach ( $ errorList as $ error ) { $ messages [ ] = $ err...
Validates the object .
8,015
protected function serialize ( $ data , $ group = self :: SERIALIZE_FULL ) { return $ this -> get ( 'serializer' ) -> serialize ( $ data , 'json' , [ 'groups' => [ $ group ] ] ) ; }
Serializes the data .
8,016
protected function getEditor ( ) { if ( null !== $ this -> editor ) { return $ this -> editor ; } return $ this -> editor = $ this -> get ( 'ekyna_cms.editor.editor' ) -> setEnabled ( true ) ; }
Returns the editor .
8,017
public static function compile ( array $ metadata , Component $ parent , $ prepend = false ) { foreach ( $ metadata as $ item ) { if ( ! $ item instanceof self ) { $ parent -> addChild ( $ item -> cloneWithContext ( $ parent -> context ) , $ prepend ) ; continue ; } $ tag = $ item -> getTagName ( ) ; $ propName = lcfir...
Converts an array of Metadata trees to actual content that can be rendered .
8,018
public static function findByPostType ( $ postTypeSlug ) { $ postType = PostType :: findBySlug ( $ postTypeSlug ) ; if ( $ postType ) { return self :: where ( 'postTypeID' , $ postType -> postTypeID ) -> get ( ) ; } return ; }
Find category by Post Type .
8,019
public static function hasPosts ( $ postType , $ categoriesID ) { if ( DB :: table ( categoriesRelationTable ( $ postType ) ) -> where ( 'categoryID' , $ categoriesID ) -> count ( ) ) { return true ; } else { return false ; } }
Check if a category has posts .
8,020
public static function isInMenuLinks ( $ categoriesID ) { $ isInMenulinks = MenuLink :: where ( 'belongsToID' , $ categoriesID ) -> where ( 'belongsTo' , 'category' ) -> count ( ) ; if ( $ isInMenulinks ) { return true ; } return false ; }
Checks if a category is part of a menulink .
8,021
public function addToMenu ( Menu $ menu ) { if ( $ this -> postTypeID ) { $ data = [ 'menuID' => $ menu -> menuID , 'belongsToID' => $ this -> categoryID , 'belongsTo' => 'category' , 'params' => $ this -> menuLinkParameters ( ) , 'routeName' => 'category.posts' ] ; foreach ( Language :: all ( ) as $ language ) { $ dat...
Add a category to a Menu .
8,022
public static function updateMenulink ( $ category ) { if ( self :: isInMenuLinks ( $ category -> categoryID ) ) { $ menuLinks = MenuLink :: where ( 'belongsToID' , $ category -> categoryID ) -> where ( 'belongsTo' , 'category' ) -> get ( ) ; foreach ( $ menuLinks as $ menuLink ) { $ menuLink -> params = $ category -> ...
Update category paremeters in MenuLink .
8,023
public function getChildren ( $ parentID ) { $ tmp = [ ] ; foreach ( $ this -> categoryList as $ key => $ item ) { if ( $ item -> parentID == $ parentID ) { $ tmp [ ] = $ item ; } } return $ tmp ; }
Get children of a category .
8,024
public function getAllChildren ( $ parentID ) { $ children = $ this -> getChildren ( $ parentID ) ; foreach ( $ children as $ key => $ child ) { $ this -> categoriesToBeDeleted [ $ child -> categoryID ] = $ child ; $ this -> getAllChildren ( $ child -> categoryID ) ; } }
Get all children tree of a parent .
8,025
public function deleteChildren ( int $ parentID , int $ postTypeID ) { $ this -> categoryList = self :: where ( "postTypeID" , $ postTypeID ) -> get ( ) ; $ this -> getAllChildren ( $ parentID ) ; foreach ( $ this -> categoriesToBeDeleted as $ cat ) { if ( self :: isInMenuLinks ( $ cat -> categoryID ) ) { return $ this...
Delete List of children .
8,026
public static function isValidHour ( $ time ) { $ result = preg_match ( '/^([0-9]{1,2}):([0-9]{1,2})(?::([0-9]{1,2}))?$/' , $ time , $ regs ) ; if ( $ result ) { $ hour = $ regs [ 1 ] ; $ minutes = $ regs [ 2 ] ; $ result = ( $ hour >= 0 && $ hour < 24 ) && ( $ minutes >= 0 && $ minutes < 60 ) ; if ( $ result && isset ...
Check for time validity
8,027
public static function concatPath ( ) { $ args = func_get_args ( ) ; $ len = count ( $ args ) ; if ( $ len == 0 ) { return '' ; } $ path = $ args [ 0 ] ; for ( $ i = 1 ; $ i < $ len ; $ i ++ ) { $ path = rtrim ( $ path , '/' ) . '/' . ltrim ( $ args [ $ i ] , '/' ) ; } return $ path ; }
Concatenate paths making sure there is no double path separator
8,028
public static function getMenuLinks ( $ menuSlug ) { MenuLink :: setActiveIDs ( true ) ; $ menuData = self :: findBySlug ( $ menuSlug ) ; $ menuLinks = MenuLink :: where ( 'menuID' , $ menuData -> menuID ) -> orderBy ( 'order' ) -> get ( ) ; if ( $ menuLinks ) { return MenuLink :: children ( $ menuLinks ) ; } }
Get menu links of a particular menu .
8,029
public static function setPrimaryMenuID ( ) { $ primaryMenu = Menu :: all ( ) -> where ( 'isPrimary' , 1 ) -> first ( ) ; if ( ! $ primaryMenu ) { $ primaryMenu = Menu :: first ( ) ; } if ( isset ( $ primaryMenu -> menuID ) ) { self :: $ primaryMenuID = $ primaryMenu -> menuID ; } return ; }
Set the ID of primary menu .
8,030
public static function printMenu ( $ menuSlug = "primary" , $ customView = '' , $ ulClass = '' ) { $ menuLinks = self :: getMenuLinks ( $ menuSlug ) ; if ( $ menuLinks ) { return new HtmlString ( view ( ) -> make ( ( $ customView ? $ customView : "vendor.menulinks.bootstrap-4" ) , [ 'menuLinks' => $ menuLinks , 'ulClas...
Prints MenuLinks of a menu .
8,031
public function getLevelName ( $ level ) { if ( ! is_int ( $ level ) ) { throw new \ Plop \ Exception ( 'Invalid level value' ) ; } if ( ! isset ( $ this -> levelNames [ $ level ] ) ) { return "Level $level" ; } return $ this -> levelNames [ $ level ] ; }
Return the name of a level given its value .
8,032
public function getLevelValue ( $ levelName ) { if ( ! is_string ( $ levelName ) ) { throw new \ Plop \ Exception ( 'Invalid level name' ) ; } $ key = array_search ( $ levelName , $ this -> levelNames , true ) ; return ( int ) $ key ; }
Return the value of a level given its name .
8,033
public function getLogger ( $ namespace = '' , $ class = '' , $ method = '' ) { $ class = substr ( $ class , strrpos ( '\\' . $ class , '\\' ) ) ; $ method = substr ( $ method , strrpos ( '\\' . $ method , '\\' ) ) ; $ method = substr ( ( string ) $ method , strrpos ( ':' . $ method , ':' ) ) ; return $ this [ "$method...
Return the logger that is most appropriate given a bit of context .
8,034
public function addLogger ( \ Plop \ LoggerInterface $ logger ) { $ loggers = func_get_args ( ) ; foreach ( $ loggers as $ logger ) { if ( ! ( $ logger instanceof \ Plop \ LoggerInterface ) ) { throw new \ Plop \ Exception ( 'Not a logger' ) ; } } foreach ( $ loggers as $ logger ) { $ this [ ] = $ logger ; } return $ t...
Register a logger .
8,035
protected static function getLoggerId ( \ Plop \ LoggerInterface $ logger ) { $ func = $ logger -> getMethod ( ) ; $ cls = $ logger -> getClass ( ) ; $ ns = $ logger -> getNamespace ( ) ; return "$func:$cls:$ns" ; }
Return a logger s identifier .
8,036
public function offsetSet ( $ offset , $ logger ) { if ( ! ( $ logger instanceof \ Plop \ LoggerInterface ) ) { throw new \ Plop \ Exception ( 'Invalid logger' ) ; } $ id = static :: getLoggerId ( $ logger ) ; if ( is_string ( $ offset ) ) { if ( $ offset != $ id ) { throw new \ Plop \ Exception ( 'Identifier mismatch'...
Register a new logger with Plop .
8,037
public function offsetGet ( $ offset ) { if ( ! is_string ( $ offset ) ) { throw new \ Plop \ Exception ( 'Invalid identifier' ) ; } $ parts = explode ( ':' , $ offset , 3 ) ; if ( count ( $ parts ) != 3 ) { throw new \ Plop \ Exception ( 'Invalid identifier' ) ; } list ( $ method , $ class , $ ns ) = $ parts ; $ len =...
Return the registered logger with the given identifier one of its parents or the root logger if no other logger can be found .
8,038
public function offsetExists ( $ offset ) { if ( $ offset instanceof \ Plop \ LoggerInterface ) { $ offset = static :: getLoggerId ( $ offset ) ; } if ( ! is_string ( $ offset ) ) { throw new \ Plop \ Exception ( 'Invalid identifier' ) ; } return isset ( $ this -> loggers [ $ offset ] ) ; }
Return a flag indicating whether a logger with the given identifier was registered with Plop .
8,039
public function offsetUnset ( $ offset ) { if ( $ offset instanceof \ Plop \ LoggerInterface ) { $ offset = static :: getLoggerId ( $ offset ) ; } if ( $ offset == "::" ) { throw new \ Plop \ Exception ( 'The root logger cannot be unset' ) ; } unset ( $ this -> loggers [ $ offset ] ) ; }
Unregister a logger .
8,040
public static function findCaller ( ) { if ( version_compare ( PHP_VERSION , '5.3.6' , '>=' ) ) { $ bt = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS ) ; } else { $ bt = debug_backtrace ( false ) ; } $ max = count ( $ bt ) ; $ ns = __NAMESPACE__ . '\\' ; $ len = strlen ( $ ns ) ; $ ns2 = $ ns . 'Tests' . '\\' ; for ( ...
Return information about the caller of this method .
8,041
protected function preRender ( RequireTagInterface $ tag ) { if ( $ this -> isNonExistentOptionalTag ( $ tag ) ) { return '' ; } $ output = $ this -> doRender ( $ tag , $ tag -> getPath ( ) ) ; $ output .= $ this -> preRenderLocalized ( $ tag ) ; return $ output ; }
Prepare the render and do the render .
8,042
protected function doRender ( RequireTagInterface $ tag , $ assetName ) { $ type = $ tag -> getType ( ) ; $ output = '' ; if ( $ this -> canBeRendered ( $ assetName , $ type ) ) { $ attributes = $ this -> prepareAttributes ( $ tag , $ assetName ) ; $ this -> assetRendered ( $ assetName , $ type ) ; $ output = RequireUt...
Do render the HTML tag .
8,043
protected function preRenderLocalized ( RequireTagInterface $ tag ) { $ output = '' ; foreach ( $ this -> getLocalizedAssets ( $ tag -> getPath ( ) ) as $ localeAsset ) { $ output .= $ this -> doRender ( $ tag , $ localeAsset ) ; } return $ output ; }
Pre render the localized assets .
8,044
protected function prepareAttributes ( RequireTagInterface $ tag , $ assetName ) { $ path = $ this -> getAssetPath ( $ assetName , $ tag -> getType ( ) ) ; $ attributes = $ tag -> getAttributes ( ) ; $ attributes [ $ tag -> getLinkAttribute ( ) ] = $ path ; return $ attributes ; }
Prepare the attributes of HTML tag .
8,045
protected function isNonExistentOptionalTag ( RequireTagInterface $ tag ) { if ( ! $ this -> manager -> has ( $ tag -> getPath ( ) , $ tag -> getType ( ) ) ) { if ( $ tag -> isOptional ( ) ) { return true ; } throw new RequireTagRendererException ( $ tag , sprintf ( 'The %s %s "%s" is not managed by the Webpack Require...
Check if the tag is a non existent optional require asset .
8,046
protected function assetRendered ( $ assets , $ type ) : void { $ assets = ( array ) $ assets ; foreach ( $ assets as $ asset ) { $ this -> renderedTags [ ] = $ type . '::' . $ asset ; } }
Indicate the asset is rendered .
8,047
public function add ( $ snippet , Callable $ callable = null ) { if ( is_object ( $ snippet ) && $ snippet instanceof Snippets ) { $ this -> addSnippetClass ( $ snippet ) ; } if ( is_string ( $ snippet ) && is_callable ( $ callable ) ) { $ this -> snippets [ $ snippet ] = $ callable ; } }
Adds one snippet or a class of Snippets .
8,048
public static function factory ( array $ oaResponse ) { if ( empty ( $ oaResponse [ 'auth' ] ) ) { throw new InvalidArgumentException ( 'The auth key is required to continue.' ) ; } if ( empty ( $ oaResponse [ 'auth' ] [ 'provider' ] ) ) { throw new InvalidArgumentException ( 'Unable to determine provider.' ) ; } $ aut...
factory Returns or creates a fresh OpauthIdentity .
8,049
public function onBeforeWrite ( ) { parent :: onBeforeWrite ( ) ; if ( ! $ this -> isInDb ( ) ) { $ this -> _isCreating = true ; $ this -> extend ( 'onBeforeCreate' ) ; } if ( $ this -> isChanged ( 'MemberID' ) ) { $ this -> extend ( 'onMemberLinked' ) ; } }
Add an extension point for creation and member linking
8,050
public function onAfterWrite ( ) { parent :: onAfterWrite ( ) ; if ( $ this -> _isCreating === true ) { $ this -> _isCreating = false ; $ this -> extend ( 'onAfterCreate' ) ; } }
Add an extension point for afterCreate
8,051
public function findOrCreateMember ( $ usrSettings = array ( ) ) { $ defaults = array ( 'linkOnMatch' => true , 'overwriteExistingFields' => false , 'overwriteEmail' => false , ) ; $ settings = array_merge ( $ defaults , $ usrSettings ) ; if ( $ this -> isInDB ( ) ) { $ member = $ this -> Member ( ) ; if ( $ member -> ...
Finds a member based on this identity . Searches existing records before creating a new Member object . Note that this method does not write anything merely sets everything up .
8,052
public function build ( $ functionName = null ) { $ parameterBuilder = new ParameterBuilder ( ) ; $ parameterBuilder -> build ( $ functionName ) ; $ signatureParameters = $ parameterBuilder -> getSignatureParameters ( ) ; $ hash = md5 ( $ signatureParameters ) ; $ this -> namespace = __NAMESPACE__ . $ hash ; if ( class...
Builds a MockDelegateFunction for a function .
8,053
public function renderSlideShow ( $ slideShowOrTag , array $ options = [ ] ) { if ( is_string ( $ slideShowOrTag ) ) { $ slideShowOrTag = $ this -> repository -> findOneBy ( [ 'tag' => $ slideShowOrTag ] ) ; } if ( ! $ slideShowOrTag instanceof SlideShow ) { throw new \ InvalidArgumentException ( "Expected tag or insta...
Returns the slide show config .
8,054
protected function encodePriority ( $ facility , $ priority ) { if ( is_string ( $ facility ) ) { $ facility = static :: $ facilityNames [ $ facility ] ; } if ( is_string ( $ priority ) ) { $ priority = static :: $ priorityNames [ $ priority ] ; } return ( $ facility << 3 ) | $ priority ; }
Encode facility & priority information .
8,055
protected function close ( ) { if ( $ this -> socket !== false ) { fclose ( $ this -> socket ) ; $ this -> socket = false ; } }
Close the socket associated with this handler .
8,056
public function detectLocale ( ) : self { $ locale = null ; $ detectors = [ FallbackDetector :: class , HiddenSegmentDetector :: class , SegmentDetector :: class , QueryDetector :: class , ] ; foreach ( $ detectors as $ detector ) { $ locale = app ( $ detector ) -> get ( $ this -> getScope ( ) , $ this -> config ) ?? $...
Detect the locale from current request url . Once the locale has been determined it will be set as the application locale . A locale is only validated if it is present within the current locale scope .
8,057
private function getMenuFromEvent ( ResourceEventInterface $ event ) { $ resource = $ event -> getResource ( ) ; if ( ! $ resource instanceof MenuInterface ) { throw new InvalidArgumentException ( "Expected instance of MenuInterface" ) ; } return $ resource ; }
Returns the menu from the event .
8,058
public function clientCredentials ( ) { if ( ! $ this -> credentials ) { $ this -> credentials = new Credentials ( 'client_credentials' ) ; $ this -> endpointDiscovery ( ) ; $ body = $ this -> acquireToken ( ) ; $ this -> credentials -> set ( $ body ) ; $ creds = serialize ( $ this -> credentials ) ; $ expiration = $ t...
Performs discovery request and gets the token
8,059
private function getOauthFields ( ) { $ this -> oAuthFields = [ 'grant_type' => 'client_credentials' , 'scope' => $ this -> scope , 'client_secret' => $ this -> mpClientSecret , 'client_id' => $ this -> mpClientId , ] ; $ this -> fieldCount = count ( $ this -> oAuthFields ) ; return $ this -> oAuthFields ; }
Field list for oAuth authentication
8,060
private function initCache ( ) { $ container = new Container ; $ container [ 'config' ] = [ 'cache.default' => 'file' , 'cache.stores.file' => [ 'driver' => 'file' , 'path' => __DIR__ . '/cache' ] ] ; $ container [ 'files' ] = new Filesystem ; $ cacheManager = new CacheManager ( $ container ) ; return $ cacheManager ->...
Create a file - based cache repository
8,061
public function fragment ( $ method , array $ params = [ ] ) { $ c = clone $ this ; $ c -> view = null ; $ c -> defaultView = $ method ; return $ c -> runTemplate ( $ method , $ params ) ; }
Render the method of a class .
8,062
protected function solveTemplatePath ( $ template ) { foreach ( array_reverse ( $ this -> templatePathSolvers ) as $ s ) { if ( ( $ r = $ s ( $ this , $ template ) ) && file_exists ( $ r ) ) return $ r ; } }
Solve the path to a template .
8,063
protected function renderDefaultTemplate ( $ template , $ params = [ ] ) { if ( ! file_exists ( $ template ) ) { $ template = $ this -> solveTemplatePath ( $ orig = $ template ) ; if ( ! file_exists ( $ template ) ) throw new \ Exception ( 'The template file "' . $ orig . '" could not be found.' ) ; } extract ( $ param...
Render the default template file .
8,064
public function get ( ) : Locale { $ locale = $ this -> originalLocale ; $ convert_locales = $ this -> config -> get ( 'convert_locales' ) ; $ conversions = $ this -> config -> get ( 'convert_locales_to' , [ ] ) ; if ( 'auto' === $ convert_locales ) { $ locale = isset ( $ conversions [ $ locale -> get ( ) ] ) ? Locale ...
Convert locale to application locale .
8,065
public static function fromLengthAndWidth ( Length $ length , Length $ width ) { $ length = $ length -> convertTo ( UnitLength :: meters ( ) ) ; $ width = $ width -> convertTo ( UnitLength :: meters ( ) ) ; $ area = $ length -> value ( ) * $ width -> value ( ) ; return new static ( $ area , UnitArea :: squareMeters ( )...
Returns the area measurement computed from the specified length and width .
8,066
public static function fromLengthAndDuration ( Length $ length , Duration $ duration ) { $ meters = $ length -> convertTo ( UnitLength :: meters ( ) ) ; $ seconds = $ duration -> convertTo ( UnitDuration :: seconds ( ) ) ; $ speed = $ meters -> value ( ) / $ seconds -> value ( ) ; return new static ( $ speed , UnitSpee...
Returns a speed measurement computed from the specified length and duration .
8,067
public function validate ( FileAbstraction $ entity , $ typeName , $ sourceFilePath = null ) { $ siblings = $ entity -> getSiblings ( ) ; $ creatingFilename = $ entity -> getFileName ( ) ; foreach ( $ siblings as $ record ) { if ( ! $ record -> equals ( $ entity ) ) { $ recordName = $ record -> getFileName ( ) ; $ crea...
Shared validation function
8,068
public function GetCachedItem ( string $ propName , string $ groupName , int $ expiriesIn , $ initFunc ) { if ( static :: $ DisableCache && $ initFunc ) { if ( GnApi :: $ Debug ) { GnLogger :: Verbose ( "Cache is disable" ) ; } return $ initFunc ( ) ; } if ( ! static :: $ CacheHandler && ! $ this -> isMemcachedConnecte...
Returns a cached item
8,069
public function ClearCache ( string $ keyPattern = NULL ) { if ( GnApi :: $ Debug ) { GnLogger :: Verbose ( "Clear cache '{$keyPattern}'" ) ; } if ( static :: $ CacheHandler ) { static :: $ CacheHandler -> deleteKey ( $ keyPattern ) ; static :: $ CacheHandler -> deleteGroup ( $ keyPattern ) ; } else { $ keys = $ this -...
Clears the items from the cache .
8,070
public static function fromLengthAndDuration ( Length $ length , Duration $ duration ) { $ meters = $ length -> convertTo ( UnitLength :: meters ( ) ) ; $ seconds = $ duration -> convertTo ( UnitDuration :: seconds ( ) ) ; $ acceleration = $ meters -> value ( ) / ( $ seconds -> value ( ) * $ seconds -> value ( ) ) ; re...
Returns an acceleration measurement computed from the specified length and duration .
8,071
public function setRenderers ( array $ renderers ) { $ this -> renderers = [ ] ; foreach ( $ renderers as $ renderer ) { $ this -> addRenderer ( $ renderer ) ; } return $ this ; }
Set the template tag renderers .
8,072
public function createTagPosition ( $ category , $ type , $ lineno = - 1 , $ name = null , $ position = null ) { $ tag = $ this -> formatTagPosition ( $ category , $ type , $ position ) ; if ( \ in_array ( $ tag , $ this -> tagPositions , true ) ) { throw new AlreadyExistTagPositionException ( $ category , $ type , $ p...
Create the tag position to included in the twig template .
8,073
public function renderTags ( $ allPosition = true ) : void { $ output = ob_get_contents ( ) ; $ start = 0 ; preg_match_all ( '/(<!--|\/\*)#tag-position:([\w0-9_:-]+):[\w0-9]+#( , $ output , $ matches , PREG_OFFSET_CAPTURE ) ; ob_clean ( ) ; $ this -> renderContents ( $ output , $ matches , $ start ) ; $ this -> validat...
Render all template tags .
8,074
protected function doRenderTags ( $ contentType ) : void { if ( isset ( $ this -> contents [ $ contentType ] ) ) { $ tags = $ this -> contents [ $ contentType ] ; $ renderers = [ ] ; $ rendererTags = [ ] ; foreach ( $ tags as $ tag ) { $ renderer = $ this -> findRenderer ( $ tag ) ; $ id = spl_object_hash ( $ renderer ...
Do render the tags by type .
8,075
protected function findRenderer ( TagInterface $ tag ) { foreach ( $ this -> getRenderers ( ) as $ renderer ) { if ( $ renderer -> validate ( $ tag ) ) { return $ renderer ; } } throw $ this -> buildRuntimeTagRendererException ( $ tag ) ; }
Find the template tag renderer .
8,076
protected function buildRuntimeTagRendererException ( TagInterface $ tag ) { $ msg = sprintf ( 'No template tag renderer has been found for the "%s_%s" tag' , $ tag -> getCategory ( ) , $ tag -> getType ( ) ) ; if ( $ tag instanceof RequireTagInterface ) { $ msg .= sprintf ( ' with the asset "%s"' , $ tag -> getPath ( ...
Build the runtime tag renderer exception .
8,077
protected function validateRenderTags ( $ allPosition = true ) : void { if ( $ allPosition && ! empty ( $ this -> contents ) ) { $ keys = array_keys ( $ this -> contents ) ; throw new MissingTagPositionException ( $ this -> contents [ $ keys [ 0 ] ] [ 0 ] ) ; } }
Validate the renderTags method .
8,078
protected function getTagPosition ( $ name , $ category ) { $ pattern = 'inline' === $ category ? '/*' . '%s' . '*/' : '<!--%s ; return sprintf ( $ pattern , '#tag-position:' . $ name . ':' . spl_object_hash ( $ this ) . '#' ) ; }
Get the tag position of inline tag .
8,079
private function createTagPositionFunction ( $ name , array $ options ) { $ options = array_merge ( $ options , [ 'node_class' => 'Fxp\Component\RequireAsset\Twig\Node\TagPositionFunctionNode' , 'is_safe' => [ 'html' ] , 'category' => null , 'type' => null , ] , $ options ) ; $ callable = [ $ this , 'createTagPosition'...
Create the tag position twig function .
8,080
public static function register ( ) { ini_set ( 'display_errors' , 0 ) ; ini_set ( 'display_startup_errors' , 0 ) ; error_reporting ( - 1 ) ; static :: $ reservedMemory = str_repeat ( 'a' , 10240 ) ; static :: $ errorAtStart = error_get_last ( ) ; $ errorHandler = new static ( ) ; set_error_handler ( [ $ errorHandler ,...
Register the PHP error handler .
8,081
public function shutdownFunction ( ) { if ( ( $ e = error_get_last ( ) ) && $ e !== static :: $ errorAtStart ) { foreach ( $ this -> ignoreDirs as $ dir ) { if ( strpos ( $ e [ 'file' ] , $ dir ) === 0 ) return ; } while ( ob_get_level ( ) ) ob_end_clean ( ) ; $ exceptionHandler = set_exception_handler ( function ( ) {...
Called on shutdown .
8,082
public function getBacktraceFromException ( $ e ) { $ trace = $ e -> getTrace ( ) ; if ( $ e instanceof FatalErrorException ) { if ( function_exists ( 'xdebug_get_function_stack' ) ) { $ trace = array_slice ( array_reverse ( xdebug_get_function_stack ( ) ) , 4 ) ; foreach ( $ trace as $ i => $ frame ) { if ( ! isset ( ...
Return backtrace from an exception .
8,083
public function phpErrorHandler ( $ errno , $ errstr , $ errfile , $ errline ) { foreach ( $ this -> ignoreDirs as $ dir ) { if ( strpos ( $ errfile , $ dir ) === 0 ) return ; } if ( $ this -> isLogging ( ) && $ this -> logPHPErrors ) $ this -> log ( \ Psr \ Log \ LogLevel :: NOTICE , 'PHP (' . static :: getPHPError ( ...
PHP Error handler .
8,084
public static function getPHPErrorSeverity ( $ code ) { $ PHP_ERROR_LEVELS = [ E_PARSE => \ Psr \ Log \ LogLevel :: ERROR , E_ERROR => \ Psr \ Log \ LogLevel :: ERROR , E_CORE_ERROR => \ Psr \ Log \ LogLevel :: ERROR , E_COMPILE_ERROR => \ Psr \ Log \ LogLevel :: ERROR , E_USER_ERROR => \ Psr \ Log \ LogLevel :: ERROR ...
Return error severity from error code .
8,085
protected function getMax ( ) { if ( ! $ this -> locked ) { } $ dql = "SELECT MAX(e.right) FROM {$this->className} e" ; $ dql .= $ this -> getAdditionalCondition ( 'WHERE' ) ; $ query = $ this -> entityManager -> createQuery ( $ dql ) ; $ max = ( int ) $ query -> getSingleScalarResult ( ) ; $ maxArrayHelper = $ this ->...
Get maximal interval value used by nodes
8,086
public function delete ( Node \ NodeInterface $ node ) { if ( ! $ this -> locked ) { } if ( ! $ node instanceof Node \ DoctrineNode ) { throw new Exception \ WrongInstance ( $ node , 'Node\DoctrineNode' ) ; } $ left = $ node -> getLeftValue ( ) ; $ right = $ node -> getRightValue ( ) ; $ sql = "DELETE FROM {$this->tabl...
Deletes the nested set part under the node including the node
8,087
public function search ( SearchCondition \ SearchConditionInterface $ filter , SelectOrder \ SelectOrderInterface $ order = null ) { $ qb = $ this -> createSearchQueryBuilder ( $ filter , $ order ) ; $ result = $ qb -> getQuery ( ) -> getResult ( ) ; return $ result ; }
Perform the search in the database
8,088
public function destroy ( ) { $ this -> arrayHelper -> destroy ( ) ; $ this -> arrayHelper = null ; $ this -> entityManager = null ; }
Prepare object for garbage collector
8,089
static function _ ( Component $ parent , array $ props = null , array $ bindings = null ) { return ( string ) static :: create ( $ parent , $ props , $ bindings ) ; }
Creates and renders a component inline .
8,090
static function create ( Component $ parent , array $ props = null , array $ bindings = null ) { return ( new static ) -> setup ( $ parent , $ parent -> context , $ props , $ bindings ) ; }
Creates a component instance of the static class where this method was invoked on .
8,091
function setProps ( array $ props = null ) { if ( $ this -> supportsProperties ( ) ) { if ( $ props ) $ this -> props -> apply ( $ props ) ; } else if ( $ props ) throw new ComponentException ( $ this , 'This component does not support properties.' ) ; }
Initializes a newly created component with the given properties if any .
8,092
function setup ( Component $ parent = null , DocumentContext $ context , $ props = null , array $ bindings = null ) { if ( is_object ( $ props ) ) { $ this -> props = $ props ; $ props = [ ] ; } $ this -> setContext ( $ context ) ; $ this -> bindings = $ bindings ; $ this -> onCreate ( $ props , $ parent ) ; $ this -> ...
Initializes a component right after instantiation .
8,093
public function onFlush ( OnFlushEventArgs $ eventArgs ) { $ em = $ eventArgs -> getEntityManager ( ) ; $ uow = $ em -> getUnitOfWork ( ) ; foreach ( $ uow -> getScheduledEntityUpdates ( ) as $ entity ) { if ( $ entity instanceof TimestampableInterface ) { $ entity -> setModificationTime ( ) ; $ className = get_class (...
Sets modification time on updates
8,094
public function addColumn ( string $ column , array $ definition = [ ] ) : Table { $ this -> data [ 'columns' ] [ $ column ] = TableColumn :: fromArray ( $ column , $ definition ) ; return $ this ; }
Add a column to the definition
8,095
public function addColumns ( array $ columns ) : Table { foreach ( $ columns as $ column => $ definition ) { if ( is_numeric ( $ column ) && is_string ( $ definition ) ) { $ this -> addColumn ( $ definition , [ ] ) ; } else { $ this -> addColumn ( $ column , $ definition ) ; } } return $ this ; }
Add columns to the definition
8,096
public function setPrimaryKey ( $ column ) : Table { if ( ! is_array ( $ column ) ) { $ column = [ $ column ] ; } $ this -> data [ 'primary' ] = $ column ; return $ this ; }
Set the primary key
8,097
public function hasOne ( Table $ toTable , string $ name = null , $ toTableColumn = null , string $ sql = null , array $ par = [ ] ) : Table { $ columns = $ toTable -> getColumns ( ) ; $ keymap = [ ] ; if ( ! isset ( $ toTableColumn ) ) { $ toTableColumn = [ ] ; } if ( ! is_array ( $ toTableColumn ) ) { $ toTableColumn...
Create a relation where each record has zero or one related rows in another table
8,098
public function manyToMany ( Table $ toTable , Table $ pivot , $ name = null , $ toTableColumn = null , $ localColumn = null ) : Table { $ pivotColumns = $ pivot -> getColumns ( ) ; $ keymap = [ ] ; if ( ! isset ( $ toTableColumn ) ) { $ toTableColumn = [ ] ; } if ( ! is_array ( $ toTableColumn ) ) { $ toTableColumn = ...
Create a relation where each record has many linked records in another table but using a liking table
8,099
public function addRelation ( TableRelation $ relation , string $ name = null ) { $ name = $ name ?? $ relation -> name ; $ relation -> name = $ name ; $ this -> relations [ $ name ] = $ relation ; return $ this ; }
Create an advanced relation using the internal array format