idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
31,800
protected function initIndexByClassName ( $ className ) { if ( false === isset ( $ this -> indexedByClassName [ $ className ] ) ) { $ this -> indexedByClassName [ $ className ] = [ ] ; } }
Initializes the index by className .
31,801
protected function setPage ( ) { $ urlTemplates = [ ] ; if ( $ this -> arParams [ 'SEF_MODE' ] === 'Y' ) { $ variables = [ ] ; $ urlTemplates = \ CComponentEngine :: MakeComponentUrlTemplates ( $ this -> defaultUrlTemplates404 , $ this -> arParams [ 'SEF_URL_TEMPLATES' ] ) ; $ variableAliases = \ CComponentEngine :: MakeComponentVariableAliases ( $ this -> defaultUrlTemplates404 , $ this -> arParams [ 'VARIABLE_ALIASES' ] ) ; $ this -> templatePage = \ CComponentEngine :: ParseComponentPath ( $ this -> arParams [ 'SEF_FOLDER' ] , $ urlTemplates , $ variables ) ; if ( ! $ this -> templatePage ) { if ( $ this -> arParams [ 'SET_404' ] === 'Y' ) { $ folder404 = str_replace ( '\\' , '/' , $ this -> arParams [ 'SEF_FOLDER' ] ) ; if ( $ folder404 != '/' ) { $ folder404 = '/' . trim ( $ folder404 , "/ \t\n\r\0\x0B" ) . "/" ; } if ( substr ( $ folder404 , - 1 ) == '/' ) { $ folder404 .= 'index.php' ; } if ( $ folder404 != Main \ Context :: getCurrent ( ) -> getRequest ( ) -> getRequestedPage ( ) ) { $ this -> return404 ( ) ; } } $ this -> templatePage = $ this -> defaultSefPage ; } if ( $ this -> isSearchRequest ( ) && $ this -> arParams [ 'USE_SEARCH' ] === 'Y' ) { $ this -> templatePage = 'search' ; } \ CComponentEngine :: InitComponentVariables ( $ this -> templatePage , $ this -> componentVariables , $ variableAliases , $ variables ) ; $ models = $ this -> setModels ( ) ; } else { $ this -> templatePage = $ this -> defaultPage ; } $ this -> sefFolder = $ this -> arParams [ 'SEF_FOLDER' ] ; $ this -> urlTemplates = $ urlTemplates ; $ this -> variables = $ variables ; $ this -> variableAliases = $ variableAliases ; $ this -> models = $ models ; }
Set type of the page
31,802
public function createPageRoute ( IRouter $ routes , string $ url ) : void { list ( $ presenter , $ action ) = explode ( ':' , $ this -> pageLink ) ; $ routes [ ] = new Route ( $ url . '[<url .*>]' , [ 'presenter' => $ presenter , 'action' => $ action , null => [ Route :: FILTER_IN => function ( $ params ) { if ( $ this -> orm -> pages -> exists ( $ params [ 'url' ] ) ) { return $ params ; } return null ; } ] , ] ) ; }
Vytvori routy stranek
31,803
public function createDefaultPageRoutes ( IRouter $ routes , string $ url ) : void { if ( $ this -> configurator -> onePage ) { $ routes [ ] = new Route ( $ url , $ this -> onePageLink ) ; $ routes [ ] = new Route ( $ url . 'index.php' , $ this -> onePageLink , Route :: ONE_WAY ) ; $ routes [ ] = new Route ( $ url . '<presenter>[/<action>]' , $ this -> defaultLink ) ; } else { $ routes [ ] = new Route ( $ url , $ this -> defaultLink ) ; $ routes [ ] = new Route ( $ url . 'index.php' , $ this -> defaultLink , Route :: ONE_WAY ) ; $ routes [ ] = new Route ( $ url . '<presenter>[/<action>]' , $ this -> defaultLink ) ; } }
Vytvori routy defaultni stranky
31,804
private function getReflection ( callable $ callable ) : \ ReflectionFunctionAbstract { if ( \ is_array ( $ callable ) ) { $ reflectionClass = new \ ReflectionClass ( $ callable [ 0 ] ) ; return $ reflectionClass -> getMethod ( $ callable [ 1 ] ) ; } if ( \ is_object ( $ callable ) && ! $ callable instanceof \ Closure ) { $ reflectionClass = new \ ReflectionClass ( $ callable ) ; return $ reflectionClass -> getMethod ( '__invoke' ) ; } return new \ ReflectionFunction ( $ callable ) ; }
To return the Reflection instance about this callable supports functions closures objects methods or class methods .
31,805
private function listParameters ( callable $ callable ) : array { $ parameters = [ ] ; foreach ( $ this -> getReflection ( $ callable ) -> getParameters ( ) as $ parameter ) { $ parameters [ $ parameter -> getName ( ) ] = $ parameter ; } return $ parameters ; }
To extract the list of ReflectionParameter instances about the current callable .
31,806
private function getParametersInOrder ( callable $ callable ) : array { if ( null === $ this -> parametersCache ) { $ this -> parametersCache = $ this -> listParameters ( $ callable ) ; } return $ this -> parametersCache ; }
To extract the list of ReflectionParameter instances about the current callable and cache them for next call .
31,807
private function extractParameters ( callable $ callable , ChefInterface $ chef , array & $ workPlan ) : array { $ values = [ ] ; foreach ( $ this -> getParametersInOrder ( $ callable ) as $ name => $ parameter ) { $ class = $ parameter -> getClass ( ) ; if ( $ class instanceof \ ReflectionClass && $ class -> isInstance ( $ chef ) ) { $ values [ ] = $ chef ; continue ; } if ( ! empty ( $ this -> mapping [ $ name ] ) ) { $ name = $ this -> mapping [ $ name ] ; } if ( isset ( $ workPlan [ $ name ] ) ) { $ values [ ] = $ workPlan [ $ name ] ; continue ; } if ( $ class instanceof \ ReflectionClass ) { $ automaticValueFound = $ this -> findInstanceForParameter ( $ class , $ workPlan , $ values ) ; if ( true === $ automaticValueFound ) { continue ; } } if ( BowlInterface :: METHOD_NAME === $ name ) { $ values [ ] = $ this -> name ; continue ; } if ( ! $ parameter -> isOptional ( ) ) { throw new \ RuntimeException ( "Missing the parameter {$parameter->getName()} in the WorkPlan" ) ; } $ values [ ] = $ parameter -> getDefaultValue ( ) ; } return $ values ; }
To map each callable s arguments to ingredients available into the workplan .
31,808
public static function getBundleName ( ) { $ path = ( new ReflectionClass ( get_called_class ( ) ) ) -> getFileName ( ) ; $ basePath = substr ( $ path , 0 , strrpos ( strtolower ( $ path ) , 'bundle' ) + 7 ) ; $ files = glob ( sprintf ( '%s/*Bundle.php' , $ basePath ) ) ; $ firstBundle = current ( $ files ) ; if ( $ firstBundle ) { return pathinfo ( $ firstBundle , PATHINFO_FILENAME ) ; } return '' ; }
Return module name .
31,809
public function highlightSpecialWords ( $ string ) { if ( $ this -> _specialWordTable === null ) { $ this -> _createSpecialWordTable ( ) ; } foreach ( $ this -> _tags as $ tag ) { $ words = $ this -> _specialWordTable [ $ tag ] ; foreach ( $ words as $ word => $ description ) { if ( mb_strstr ( $ string , $ word ) ) { $ tpl = $ this -> _templates [ $ tag ] ; $ html = str_replace ( '{$WORD}' , $ word , str_replace ( '{$DESC}' , $ description , $ tpl ) ) ; $ string = str_replace ( $ word , $ html , $ string ) ; } } } return $ string ; }
This method is intend to return a string with highlighted acronyms definitions and abbreviations .
31,810
public function removeBadWords ( $ string ) { if ( ! $ this -> _badWordTable ) { $ this -> _createBadWordTable ( ) ; } $ words = explode ( ' ' , trim ( $ string ) ) ; try { $ replacecharacter = $ this -> getConfiguration ( ) -> words -> replacecharacter ; } catch ( Doozr_Configuration_Service_Exception $ exception ) { $ replacecharacter = '*' ; } foreach ( $ words as $ key => $ word ) { $ word = preg_replace ( '/[^a-zA-Z0-9]+/' , '' , $ word ) ; foreach ( $ this -> _badWordTable as $ badWord ) { if ( preg_match ( '/^' . $ badWord . '/im' , $ word ) ) { $ words [ $ key ] = preg_replace ( '/^' . $ badWord . '+/im' , str_repeat ( $ replacecharacter , mb_strlen ( $ badWord ) ) , $ word ) ; break ; } } } $ result = implode ( ' ' , $ words ) ; return $ result ; }
This method is intend to remove a bad - word from a given string .
31,811
private function _createSpecialWordTable ( ) { $ config = $ this -> getConfiguration ( ) ; $ this -> _specialWordTable = [ ] ; foreach ( $ this -> _tags as $ tag ) { $ this -> _specialWordTable [ $ tag ] = $ this -> config -> { $ tag } ; } }
This method is intend to create the special - word table .
31,812
private function _createBadWordTable ( ) { $ config = $ this -> getConfiguration ( ) ; $ this -> _badWordTable = [ ] ; $ badWords = explode ( ',' , $ config -> words -> badwords ) ; foreach ( $ badWords as $ badWord ) { $ this -> _badWordTable [ ] = trim ( $ badWord ) ; } }
This method is intend to create the bad - word table .
31,813
public function generate ( $ cache ) { $ item = new Item ; $ item -> results = $ this -> element -> generate ( $ cache ) ; $ item -> name = 'item' . $ this -> id ; $ item -> template = $ this -> template ; $ item -> cssid = $ this -> cssId ; $ item -> cssclass = $ this -> cssClass ; return $ item ; }
Item generation .
31,814
public function getPostCountAttribute ( ) { if ( ! array_key_exists ( 'postCount' , $ this -> relations ) ) $ this -> load ( 'postCount' ) ; $ related = $ this -> getRelation ( 'postCount' ) -> first ( ) ; return ( $ related ) ? $ related -> aggregate : 0 ; }
accessor for easier fetching the count
31,815
private function buildQueue ( ) : array { $ queue = [ ] ; $ parentMiddleware = $ this -> config -> paths -> theme -> parent -> middleware ; $ childMiddleware = $ this -> config -> paths -> theme -> child -> middleware ; foreach ( $ this -> finder -> createFinder ( ) -> files ( ) -> name ( '*.php' ) -> in ( $ parentMiddleware ) as $ file ) { if ( $ this -> kernel -> childHasMiddleware ( ) ) { if ( ! file_exists ( str_replace ( $ parentMiddleware , $ childMiddleware , $ file ) ) ) { $ queue [ ] = $ file ; } } else { $ queue [ ] = $ file ; } } if ( $ this -> kernel -> childHasMiddleware ( ) ) { foreach ( $ this -> finder -> createFinder ( ) -> files ( ) -> name ( '*.php' ) -> in ( $ childMiddleware ) as $ file ) { $ queue [ ] = $ file ; } } return Linq :: from ( $ queue ) -> orderBy ( '$v' ) -> toArray ( ) ; }
Creates an array of file paths that contain middleware .
31,816
private function resolve ( SplFileInfo $ file ) : Closure { return function ( IServerRequest $ request , IResponse $ response , callable $ next ) use ( $ file ) { return $ this -> container -> call ( import ( $ file -> getRealPath ( ) ) , [ 'request' => $ request , 'response' => $ response , 'next' => $ next , 'config' => $ this -> config ] ) ; } ; }
Used by Relay \ Runner when it dispatches the middleware stack .
31,817
public function isAuthorized ( $ user = null ) { $ result = false ; if ( empty ( $ this -> prefixes ) || ! is_array ( $ this -> prefixes ) ) { return $ result ; } $ rolePrefix = ( string ) $ this -> _objUserInfo -> getUserField ( 'prefix' , $ user ) ; if ( ! empty ( $ rolePrefix ) ) { if ( ! in_array ( $ rolePrefix , $ this -> prefixes ) ) { return $ result ; } $ prefixes = [ $ rolePrefix ] ; } else { $ prefixes = $ this -> prefixes ; } $ action = $ this -> _controller -> request -> param ( 'action' ) ; foreach ( $ prefixes as $ prefix ) { if ( mb_stripos ( $ action , $ prefix . '_' ) === 0 ) { $ result |= true ; } else { $ result |= false ; } } if ( empty ( $ rolePrefix ) ) { $ result = ! $ result ; } return ( bool ) $ result ; }
Checking the requested controller action on the user s access by prefix role
31,818
public function handleClass ( $ class_name , $ force = false ) { if ( is_string ( $ class_name ) ) { $ entity_class = str_replace ( 'Service' , '' , $ class_name ) ; } elseif ( is_object ( $ class_name ) ) { $ entity_class = get_class ( $ class_name ) ; } else { throw new \ Exception ( 'param $class_name is not classname or object' ) ; } $ disco = new SoapDiscovery ( $ entity_class ) ; if ( isset ( $ _SERVER [ 'QUERY_STRING' ] ) && strcasecmp ( $ _SERVER [ 'QUERY_STRING' ] , 'wsdl' ) == 0 ) { header ( "Content-type: text/xml" ) ; echo $ disco -> getWSDL ( ) ; } else { $ options = [ 'soap_version' => $ this -> options [ 'soap_version' ] , ] ; $ wsdl_url = $ disco -> createWSDL ( ) ; $ servidorSoap = new SoapServer ( $ wsdl_url , $ options ) ; $ servidorSoap -> setClass ( $ entity_class ) ; $ servidorSoap -> handle ( ) ; } }
webservice handle class
31,819
function loadModules ( array $ modules ) { $ modules = array_diff ( $ modules , array_keys ( $ this -> _c__loadedModules ) ) ; if ( empty ( $ modules ) ) return $ this ; foreach ( $ modules as $ im => $ vm ) { if ( is_string ( $ im ) && $ vm ) $ module = array ( $ im => $ vm ) ; else $ module = $ vm ; $ this -> loadModule ( $ module ) ; } $ collectorPass = new DataCollectorModuleManager ; $ collectorPass -> setModuleManager ( $ this ) ; $ this -> event ( ) -> trigger ( EventHeapOfModuleManager :: EVENT_MODULES_POSTLOAD , $ collectorPass ) ; return $ this ; }
Load Modules By Names List
31,820
function loadModule ( $ module ) { $ moduleNameStr = $ module ; if ( is_array ( $ module ) ) { if ( empty ( $ module ) || array_values ( $ module ) === $ module || count ( $ module ) > 1 ) throw new \ Exception ( 'Module in form of array can be ["moduleName" => X], X can be either Module Class Map or Module Object Instance' ) ; $ moduleNameStr = key ( $ module ) ; } if ( $ this -> hasLoaded ( $ moduleNameStr ) ) return $ this ; $ collectorPass = new DataCollectorModuleManager ; $ collectorPass -> setModule ( $ module ) ; $ collectorPass -> setModuleManager ( $ this ) ; $ resolvedModule = $ this -> event ( ) -> trigger ( EventHeapOfModuleManager :: EVENT_RESOLVE_TO_MODULE , $ collectorPass , new MeeterCallable ( function ( $ result , MeeterCallable $ self ) { $ event = $ self -> event ( ) ; $ resolvedModule = $ result ; if ( $ resolvedModule ) { $ event -> collector ( ) -> setModuleResolved ( $ resolvedModule ) ; $ event -> stopPropagation ( ) ; } return $ resolvedModule ; } ) ) -> trigger ( ModuleManager \ EventHeapOfModuleManager :: EVENT_INITIALIZE_MODULE ) -> then ( function ( DataCollectorModuleManager $ result ) { return $ result -> getModuleResolved ( ) ; } ) ; ( ! $ resolvedModule ) ? : $ this -> _c__loadedModules [ $ moduleNameStr ] = $ resolvedModule ; return $ this ; }
Get Module Instance By Name
31,821
function byModule ( $ moduleName ) { if ( ! $ this -> hasLoaded ( $ moduleName ) ) $ this -> loadModule ( $ moduleName ) ; return $ this -> _c__loadedModules [ $ moduleName ] ; }
Get Loaded Module Instance
31,822
function hasLoaded ( $ moduleName ) { if ( ! is_string ( $ moduleName ) ) throw new \ InvalidArgumentException ( sprintf ( 'Invalid module name, "%s".' , \ Poirot \ Std \ flatten ( $ moduleName ) ) ) ; return in_array ( $ moduleName , $ this -> listLoadedModules ( ) ) ; }
Has Module Loaded
31,823
public function validate ( ) { $ errors = array ( ) ; $ enabled_servers = ldap_servers_get_servers ( NULL , 'enabled' ) ; if ( $ this -> ssoEnabled ) { foreach ( $ this -> sids as $ sid => $ discard ) { if ( $ enabled_servers [ $ sid ] -> bind_method == LDAP_SERVERS_BIND_METHOD_USER || $ enabled_servers [ $ sid ] -> bind_method == LDAP_SERVERS_BIND_METHOD_ANON_USER ) { $ methods = array ( LDAP_SERVERS_BIND_METHOD_USER => 'Bind with Users Credentials' , LDAP_SERVERS_BIND_METHOD_ANON_USER => 'Anonymous Bind for search, then Bind with Users Credentials' , ) ; $ tokens = array ( '!edit' => l ( $ enabled_servers [ $ sid ] -> name , LDAP_SERVERS_INDEX_BASE_PATH . '/edit/' . $ sid ) , '%sid' => $ sid , '%bind_method' => $ methods [ $ enabled_servers [ $ sid ] -> bind_method ] , ) ; $ errors [ 'ssoEnabled' ] = t ( 'Single Sign On is not valid with the server !edit (id=%sid) because that server configuration uses %bind_method. Since the user\'s credentials are never available to this module with single sign on enabled, there is no way for the ldap module to bind to the ldap server with credentials.' , $ tokens ) ; } } } return $ errors ; }
validate object not form
31,824
public function addSetterHook ( string $ propertyName , Closure $ hook ) : self { $ this -> propertyDefinition -> addSetterHook ( $ propertyName , $ hook ) ; return $ this ; }
Add a hook for setter with first in last out rule .
31,825
public function addGetterHook ( string $ propertyName , Closure $ hook ) : self { $ this -> propertyDefinition -> addGetterHook ( $ propertyName , $ hook ) ; return $ this ; }
Add a hook for getter with first in last out rule .
31,826
public function create_cookie ( $ name , $ value , $ minutes = 0 , $ path = null , $ domain = null , $ secure = false , $ httponly = true ) { $ expire = ( 0 === $ minutes ) ? 0 : ( time ( ) + $ minutes * MINUTE_IN_SECONDS ) ; return new Cookie ( $ name , $ value , $ expire , $ path ? : COOKIEPATH , $ domain ? : COOKIE_DOMAIN , $ secure , $ httponly ) ; }
Create a Cookie instance .
31,827
public function parse ( $ input , array $ aliases = array ( ) ) { if ( 0 !== strpos ( ltrim ( $ input ) , '/**' ) ) { return array ( ) ; } if ( false == ( $ position = strpos ( $ input , '@' ) ) ) { return array ( ) ; } if ( 0 < $ position ) { $ position -= 1 ; } $ input = substr ( $ input , $ position ) ; $ input = trim ( $ input , '*/ ' ) ; $ this -> aliases = $ aliases ; $ this -> lexer -> setInput ( $ input ) ; $ this -> lexer -> moveNext ( ) ; return $ this -> getAnnotations ( ) ; }
Parses the docblock and returns its annotation tokens .
31,828
private function getAnnotation ( ) { $ this -> match ( DocLexer :: T_AT ) ; $ identifier = $ this -> getIdentifier ( ) ; if ( in_array ( $ identifier , $ this -> ignored ) ) { return null ; } if ( false !== ( $ pos = strpos ( $ identifier , '\\' ) ) ) { $ alias = substr ( $ identifier , 0 , $ pos ) ; if ( isset ( $ this -> aliases [ $ alias ] ) ) { $ identifier = $ this -> aliases [ $ alias ] . '\\' . substr ( $ identifier , $ pos + 1 ) ; } } elseif ( isset ( $ this -> aliases [ $ identifier ] ) ) { $ identifier = $ this -> aliases [ $ identifier ] ; } return array_merge ( array ( array ( DocLexer :: T_AT ) , array ( DocLexer :: T_IDENTIFIER , $ identifier ) ) , $ this -> getValues ( ) ) ; }
Returns the tokens for the next annotation .
31,829
private function getAnnotations ( ) { $ tokens = array ( ) ; while ( null !== $ this -> lexer -> lookahead ) { if ( DocLexer :: T_AT !== $ this -> lexer -> lookahead [ 'type' ] ) { $ this -> lexer -> moveNext ( ) ; continue ; } $ position = $ this -> lexer -> token [ 'position' ] + strlen ( $ this -> lexer -> token [ 'value' ] ) ; if ( ( null !== $ this -> lexer -> token ) && ( $ this -> lexer -> lookahead [ 'position' ] === $ position ) ) { $ this -> lexer -> moveNext ( ) ; continue ; } if ( ( null === ( $ glimpse = $ this -> lexer -> glimpse ( ) ) ) || ( ( DocLexer :: T_NAMESPACE_SEPARATOR !== $ glimpse [ 'type' ] ) && ! in_array ( $ glimpse [ 'type' ] , self :: $ classIdentifiers ) ) ) { $ this -> lexer -> moveNext ( ) ; continue ; } if ( null !== ( $ token = $ this -> getAnnotation ( ) ) ) { $ tokens = array_merge ( $ tokens , $ token ) ; } } return $ tokens ; }
Returns the tokens for all available annotations .
31,830
private function getArray ( ) { $ this -> match ( DocLexer :: T_OPEN_CURLY_BRACES ) ; $ tokens = array ( array ( DocLexer :: T_OPEN_CURLY_BRACES ) ) ; if ( $ this -> lexer -> isNextToken ( DocLexer :: T_CLOSE_CURLY_BRACES ) ) { $ this -> match ( DocLexer :: T_CLOSE_CURLY_BRACES ) ; $ tokens [ ] = array ( DocLexer :: T_CLOSE_CURLY_BRACES ) ; return $ tokens ; } $ tokens = array_merge ( $ tokens , $ this -> getArrayEntry ( ) ) ; while ( $ this -> lexer -> isNextToken ( DocLexer :: T_COMMA ) ) { $ this -> match ( DocLexer :: T_COMMA ) ; $ tokens [ ] = array ( DocLexer :: T_COMMA ) ; if ( $ this -> lexer -> isNextToken ( DocLexer :: T_CLOSE_CURLY_BRACES ) ) { break ; } $ tokens = array_merge ( $ tokens , $ this -> getArrayEntry ( ) ) ; } $ this -> match ( DocLexer :: T_CLOSE_CURLY_BRACES ) ; $ tokens [ ] = array ( DocLexer :: T_CLOSE_CURLY_BRACES ) ; return $ tokens ; }
Returns the tokens for the next array of values .
31,831
private function getArrayEntry ( ) { $ glimpse = $ this -> lexer -> glimpse ( ) ; $ tokens = array ( ) ; if ( DocLexer :: T_COLON === $ glimpse [ 'type' ] ) { $ token = array ( DocLexer :: T_COLON ) ; } elseif ( DocLexer :: T_EQUALS === $ glimpse [ 'type' ] ) { $ token = array ( DocLexer :: T_EQUALS ) ; } if ( isset ( $ token ) ) { if ( $ this -> lexer -> isNextToken ( DocLexer :: T_IDENTIFIER ) ) { $ tokens = $ this -> getConstant ( ) ; } else { $ this -> matchAny ( array ( DocLexer :: T_INTEGER , DocLexer :: T_STRING ) ) ; $ tokens = array ( array ( $ this -> lexer -> token [ 'type' ] , $ this -> lexer -> token [ 'value' ] ) ) ; } $ tokens [ ] = $ token ; $ this -> matchAny ( array ( DocLexer :: T_COLON , DocLexer :: T_EQUALS ) ) ; } return array_merge ( $ tokens , $ this -> getPlainValue ( ) ) ; }
Returns the tokens for the next array entry .
31,832
private function getConstant ( ) { $ identifier = $ this -> getIdentifier ( ) ; $ tokens = array ( ) ; switch ( strtolower ( $ identifier ) ) { case 'true' : $ tokens [ ] = array ( DocLexer :: T_TRUE , $ identifier ) ; break ; case 'false' : $ tokens [ ] = array ( DocLexer :: T_FALSE , $ identifier ) ; break ; case 'null' : $ tokens [ ] = array ( DocLexer :: T_NULL , $ identifier ) ; break ; default : $ tokens [ ] = array ( DocLexer :: T_IDENTIFIER , $ identifier ) ; } return $ tokens ; }
Returns the current constant value for the current annotation .
31,833
private function getIdentifier ( ) { if ( $ this -> lexer -> isNextTokenAny ( self :: $ classIdentifiers ) ) { $ this -> lexer -> moveNext ( ) ; $ name = $ this -> lexer -> token [ 'value' ] ; } else { throw SyntaxException :: expectedToken ( 'namespace separator or identifier' , null , $ this -> lexer ) ; } $ position = $ this -> lexer -> token [ 'position' ] + strlen ( $ this -> lexer -> token [ 'value' ] ) ; while ( ( $ this -> lexer -> lookahead [ 'position' ] === $ position ) && $ this -> lexer -> isNextToken ( DocLexer :: T_NAMESPACE_SEPARATOR ) ) { $ this -> match ( DocLexer :: T_NAMESPACE_SEPARATOR ) ; $ this -> matchAny ( self :: $ classIdentifiers ) ; $ name .= '\\' . $ this -> lexer -> token [ 'value' ] ; } return $ name ; }
Returns the next identifier .
31,834
private function getPlainValue ( ) { if ( $ this -> lexer -> isNextToken ( DocLexer :: T_OPEN_CURLY_BRACES ) ) { return $ this -> getArray ( ) ; } if ( $ this -> lexer -> isNextToken ( DocLexer :: T_AT ) ) { return $ this -> getAnnotation ( ) ; } if ( $ this -> lexer -> isNextToken ( DocLexer :: T_IDENTIFIER ) ) { return $ this -> getConstant ( ) ; } $ tokens = array ( ) ; switch ( $ this -> lexer -> lookahead [ 'type' ] ) { case DocLexer :: T_FALSE : case DocLexer :: T_FLOAT : case DocLexer :: T_INTEGER : case DocLexer :: T_NULL : case DocLexer :: T_STRING : case DocLexer :: T_TRUE : $ this -> match ( $ this -> lexer -> lookahead [ 'type' ] ) ; $ tokens [ ] = array ( $ this -> lexer -> token [ 'type' ] , $ this -> lexer -> token [ 'value' ] ) ; break ; default : throw SyntaxException :: expectedToken ( 'PlainValue' , null , $ this -> lexer ) ; } return $ tokens ; }
Returns the tokens for the next plain value .
31,835
private function getValue ( ) { $ glimpse = $ this -> lexer -> glimpse ( ) ; if ( DocLexer :: T_EQUALS === $ glimpse [ 'type' ] ) { return $ this -> getAssignedValue ( ) ; } return $ this -> getPlainValue ( ) ; }
Returns the tokens for the next value .
31,836
private function getValues ( ) { $ tokens = array ( ) ; if ( $ this -> lexer -> isNextToken ( DocLexer :: T_OPEN_PARENTHESIS ) ) { $ this -> match ( DocLexer :: T_OPEN_PARENTHESIS ) ; $ tokens [ ] = array ( DocLexer :: T_OPEN_PARENTHESIS ) ; if ( $ this -> lexer -> isNextToken ( DocLexer :: T_CLOSE_PARENTHESIS ) ) { $ this -> match ( DocLexer :: T_CLOSE_PARENTHESIS ) ; $ tokens [ ] = array ( DocLexer :: T_CLOSE_PARENTHESIS ) ; return $ tokens ; } } else { return $ tokens ; } $ tokens = array_merge ( $ tokens , $ this -> getValue ( ) ) ; while ( $ this -> lexer -> isNextToken ( DocLexer :: T_COMMA ) ) { $ this -> match ( DocLexer :: T_COMMA ) ; $ tokens [ ] = array ( DocLexer :: T_COMMA ) ; $ token = $ this -> lexer -> lookahead ; $ value = $ this -> getValue ( ) ; if ( empty ( $ value ) ) { throw SyntaxException :: expectedToken ( 'Value' , $ token ) ; } $ tokens = array_merge ( $ tokens , $ value ) ; } $ this -> match ( DocLexer :: T_CLOSE_PARENTHESIS ) ; $ tokens [ ] = array ( DocLexer :: T_CLOSE_PARENTHESIS ) ; return $ tokens ; }
Returns the tokens for all of the values for the current annotation .
31,837
private function match ( $ token ) { if ( ! $ this -> lexer -> isNextToken ( $ token ) ) { throw SyntaxException :: expectedToken ( $ this -> lexer -> getLiteral ( $ token ) , null , $ this -> lexer ) ; } return $ this -> lexer -> moveNext ( ) ; }
Matches the next token and advances .
31,838
private function matchAny ( array $ tokens ) { if ( ! $ this -> lexer -> isNextTokenAny ( $ tokens ) ) { throw SyntaxException :: expectedToken ( implode ( ' or ' , array_map ( array ( $ this -> lexer , 'getLiteral' ) , $ tokens ) ) , null , $ this -> lexer ) ; } return $ this -> lexer -> moveNext ( ) ; }
Matches any one of the tokens and advances .
31,839
function Invert ( ) { $ this -> r = 0xff - $ this -> r ; $ this -> g = 0xff - $ this -> g ; $ this -> b = 0xff - $ this -> b ; }
Inverts the color
31,840
private function LightenColor ( $ color , $ amount ) { $ newColor = $ color + ( 0xff - $ color ) * $ amount ; return min ( max ( round ( $ newColor ) , 0x00 ) , 0xff ) ; }
Lightens a single color part
31,841
private function DarkenColor ( $ color , $ amount ) { $ newColor = $ color * ( 1 - $ amount ) ; return min ( max ( round ( $ newColor ) , 0x00 ) , 0xff ) ; }
Darkens a single color part
31,842
static public function verify_username ( $ value ) { if ( is_numeric ( $ value ) ) { return true ; } elseif ( static :: verify_email ( $ value ) ) { return true ; } else { $ regex = "^[a-z0-9\!\@\#\$\%\&\*\_\-\=]+$" ; return static :: verify_regex ( $ regex , $ value , 'i' ) ; } }
verify username [ a - z0 - 9_ -
31,843
static public function formatPath ( $ value ) { $ value = preg_replace ( '/\s+/u' , '_' , $ value ) ; $ value = preg_replace ( '/[^a-z0-9\.\:\-\_\s\/\\\\\x{4e00}-\x{9fa5}]/iu' , '' , $ value ) ; $ value = preg_replace ( '/\/{2,}/' , '/' , $ value ) ; $ value = preg_replace ( '/(\.\/?){2,}/' , '' , $ value ) ; return $ value ; }
format filesystem path
31,844
static public function formatSearch ( $ value ) { $ value = static :: filter_xss ( $ value ) ; $ value = static :: html_entities ( $ value ) ; $ value = str_replace ( '&lt;' , '' , $ value ) ; $ value = str_replace ( '&gt;' , '' , $ value ) ; $ value = static :: sql_encode ( $ value ) ; $ value = trim ( $ value ) ; return $ value ; }
format search text do filter xss and sql encode
31,845
function unicode_encode ( $ value , $ prefix = '\u' , $ parse_alpha = true , $ exclude_str = null ) { if ( $ prefix ) { if ( strpos ( $ prefix , '\\' ) !== 0 ) { $ prefix = '\\' . $ prefix ; } if ( $ prefix !== '\\u' && $ prefix !== '\\x' ) { $ prefix = '\\u' ; } } $ value = iconv ( 'UTF-8' , 'UCS-2' , $ value ) ; $ len = strlen ( $ value ) ; $ newStr = '' ; for ( $ i = 0 ; $ i < $ len - 1 ; $ i = $ i + 2 ) { $ c = $ value [ $ i ] ; $ c2 = $ value [ $ i + 1 ] ; if ( ord ( $ c ) > 0 ) { $ newStr .= '\\u' . strtoupper ( base_convert ( ord ( $ c ) , 10 , 16 ) . base_convert ( ord ( $ c2 ) , 10 , 16 ) ) ; } else { if ( $ exclude_str && strpos ( $ exclude_str , $ c2 ) !== false ) { $ newStr .= $ c2 ; } else { if ( $ prefix == '\\u' ) { $ newStr .= $ parse_alpha ? '\\u00' . strtoupper ( bin2hex ( $ c2 ) ) : $ c2 ; } else { $ newStr .= $ parse_alpha ? '\\x' . strtoupper ( bin2hex ( $ c2 ) ) : $ c2 ; } } } } return $ newStr ; }
from str to unicode format \ uAAAA
31,846
static public function toDate ( $ value = null ) { if ( ! $ value ) { return date ( 'Y-m-d' ) ; } else { if ( is_numeric ( $ value ) ) { $ value = strftime ( '%Y-%m-%d' , $ value ) ; } return $ value ; } }
to date like 2010 - 01 - 01
31,847
static public function extract ( $ data , $ keys = null ) { if ( $ data ) { if ( $ keys ) { $ list = [ ] ; $ keys = static :: explode ( '\,\|' , $ keys ) ; foreach ( $ keys as $ k ) { $ list [ ] = isset ( $ data [ $ k ] ) ? $ data [ $ k ] : null ; } return $ list ; } } return $ data ; }
extract array by keys
31,848
public function getPerPageLimit ( ) { ob_start ( ) ; $ selection = explode ( ',' , $ this -> perPageSelection ) ; ?> <div class="field filter-option-lg form-group"> <label class="field-label" for="#attention-of-search">Per page</label> <select name="per_page" class="per-page form-control" data-width="80px" > <?php foreach ( $ selection as $ val ) : $ selected_attr = ( $ val == $ this -> perPage ) ? "selected=\"selected\"" : null ; ?> <option <?php echo $ selected_attr ; ?> class=" <?php echo $ val ; ?> "> <?php echo $ val ; ?> </option> <?php endforeach ; ?> </select> </div> <?php return ob_get_clean ( ) ; }
generate a per page select block
31,849
protected function addHistory ( $ method , $ arguments ) { if ( ! isset ( $ this -> history [ $ method ] ) ) { $ this -> history [ $ method ] = [ ] ; } $ this -> history [ $ method ] [ ] = $ arguments ; return $ this ; }
Adds a history entry to collection .
31,850
private function prepareResultPage ( $ data ) { $ type = $ this -> getOutDataType ( ) ; $ stdObj = $ this -> outputProcessor -> convertValue ( $ data , $ type ) ; $ result = $ this -> resultFactory -> create ( AResultFactory :: TYPE_JSON ) ; $ result -> setData ( $ stdObj ) ; return $ result ; }
Convert PHP object from service into JSON result page .
31,851
public function run ( ) { $ results = [ $ this -> doDelete ( ) , $ this -> doUpdate ( ) , $ this -> doCreate ( ) ] ; return array_search ( false , $ results , true ) === false ; }
Runs the update package . This runs the pre - checks and a live upgrade .
31,852
public static function logIn ( $ username , $ password ) { if ( ! $ username ) { throw new AVException ( "Cannot log in user with an empty name" ) ; } if ( ! $ password ) { throw new AVException ( "Cannot log in user with an empty password." ) ; } $ data = array ( "username" => $ username , "password" => $ password ) ; $ result = AVClient :: _request ( "GET" , "/login" , "" , $ data ) ; $ user = new AVUser ( ) ; $ user -> _mergeAfterFetch ( $ result ) ; $ user -> handleSaveResult ( true ) ; AVClient :: getStorage ( ) -> set ( "user" , $ user ) ; return $ user ; }
Logs in a and returns a valid AVUser or throws if invalid .
31,853
public static function logInWithMobilePhone ( $ mobilePhoneNumber , $ password ) { if ( ! $ mobilePhoneNumber ) { throw new AVException ( "Cannot log in user with an empty phone" ) ; } if ( ! $ password ) { throw new AVException ( "Cannot log in user with an empty password." ) ; } $ data = array ( "mobilePhoneNumber" => $ mobilePhoneNumber , "password" => $ password ) ; $ result = AVClient :: _request ( "GET" , "/login" , "" , $ data ) ; $ user = new AVUser ( ) ; $ user -> _mergeAfterFetch ( $ result ) ; $ user -> handleSaveResult ( true ) ; AVClient :: getStorage ( ) -> set ( "user" , $ user ) ; return $ user ; }
Logs in with mobile phone and returns a valid AVUser or throws if invalid .
31,854
private function handleSaveResult ( $ makeCurrent = false ) { if ( isset ( $ this -> serverData [ 'password' ] ) ) { unset ( $ this -> serverData [ 'password' ] ) ; } if ( isset ( $ this -> serverData [ 'sessionToken' ] ) ) { $ this -> _sessionToken = $ this -> serverData [ 'sessionToken' ] ; unset ( $ this -> serverData [ 'sessionToken' ] ) ; } if ( $ makeCurrent ) { static :: $ currentUser = $ this ; static :: saveCurrentUser ( ) ; } $ this -> rebuildEstimatedData ( ) ; }
After a save perform User object specific logic .
31,855
public static function getCurrentUser ( ) { if ( static :: $ currentUser instanceof AVUser ) { return static :: $ currentUser ; } $ storage = AVClient :: getStorage ( ) ; $ userData = $ storage -> get ( "user" ) ; if ( $ userData instanceof AVUser ) { static :: $ currentUser = $ userData ; return $ userData ; } if ( isset ( $ userData [ "id" ] ) && isset ( $ userData [ "_sessionToken" ] ) ) { $ user = AVUser :: create ( "_User" , $ userData [ "id" ] ) ; unset ( $ userData [ "id" ] ) ; $ user -> _sessionToken = $ userData [ "_sessionToken" ] ; unset ( $ userData [ "_sessionToken" ] ) ; foreach ( $ userData as $ key => $ value ) { $ user -> set ( $ key , $ value ) ; } $ user -> _opSetQueue = array ( ) ; static :: $ currentUser = $ user ; return $ user ; } return null ; }
Retrieves the currently logged in AVUser with a valid session either from memory or the storage provider if necessary .
31,856
public function isCurrent ( ) { if ( AVUser :: getCurrentUser ( ) && $ this -> getObjectId ( ) ) { if ( $ this -> getObjectId ( ) == AVUser :: getCurrentUser ( ) -> getObjectId ( ) ) { return true ; } } return false ; }
Returns true if this user is the current user .
31,857
public function bootIfNotBooted ( ) { if ( isset ( $ this -> defaultValues ) || is_array ( $ this -> defaultValues ) || ! empty ( $ this -> defaultValues ) ) { $ attributes = array_replace_recursive ( $ this -> defaultValues , $ this -> attributes ) ; $ this -> fill ( $ attributes ) ; } parent :: bootIfNotBooted ( ) ; }
Override Eloquent method .
31,858
static public function detectClientType ( ) { $ clientType = static :: PC ; if ( HttpHelper :: isMobile ( ) ) { if ( HttpHelper :: isWechat ( ) ) { $ clientType = static :: WX ; } elseif ( HttpHelper :: isAlipay ( ) ) { $ clientType = static :: ALIPAY ; } else { $ clientType = static :: MOBILE ; } } return $ clientType ; }
detect client type return pc|mobile|wx|alipay
31,859
public function all ( $ keys = null ) { $ input = array_replace_recursive ( $ this -> input ( ) , $ this -> all_files ( ) ) ; if ( ! $ keys ) { return $ input ; } $ results = [ ] ; foreach ( is_array ( $ keys ) ? $ keys : func_get_args ( ) as $ key ) { Arr :: set ( $ results , $ key , Arr :: get ( $ input , $ key ) ) ; } return $ results ; }
Get all of the input and files for the request .
31,860
public function toArray ( ) : array { $ output = [ ] ; foreach ( $ this -> data as $ key => $ val ) { $ output [ $ key ] = $ val instanceof ArraySerializable ? $ val -> toArray ( ) : $ val ; } return $ output ; }
Array representation of this entity .
31,861
public function forClass ( $ className ) { $ parents = $ this -> getParents ( $ className ) ; $ finalConfig = array ( ) ; foreach ( $ parents as $ parent ) { if ( isset ( $ this -> options [ $ parent ] ) && count ( $ this -> options [ $ parent ] ) ) { foreach ( $ this -> options [ $ parent ] as $ name => $ option ) $ finalConfig [ $ name ] = $ option ; } } return $ finalConfig ; }
Returns config for a specific class . It will also check class parents and add extra config for each of them .
31,862
private function getParents ( $ name ) { if ( ! isset ( $ this -> _parents [ $ name ] ) ) { $ class = new \ ReflectionClass ( $ name ) ; $ parents = array ( $ name ) ; $ interfaces = $ class -> getInterfaceNames ( ) ; while ( $ class = $ class -> getParentClass ( ) ) $ parents [ ] = $ class -> getName ( ) ; $ this -> _parents [ $ name ] = array_reverse ( $ parents ) ; foreach ( $ interfaces as $ int ) { $ this -> _parents [ $ name ] [ ] = $ int ; } } return $ this -> _parents [ $ name ] ; }
Get all parent class and implemented interfaces for selected class ;
31,863
public function set ( $ className , $ values ) { if ( ! isset ( $ this -> options [ $ className ] ) ) { $ this -> options [ $ className ] = array ( ) ; } foreach ( $ values as $ k => $ v ) { $ this -> options [ $ className ] [ $ k ] = $ v ; } return $ this ; }
Update config for a specified class .
31,864
public function invokeFunction ( $ function , array $ args = array ( ) ) { if ( ! $ function || ! is_string ( $ function ) || '' === $ function ) { throw new InvalidArgumentException ( _ ( 'Missing valid function to invoke.' ) ) ; } try { $ reflection = new ReflectionFunction ( $ function ) ; $ ordered_arguments = Helper :: parseParams ( $ reflection -> getParameters ( ) , $ args ) ; return $ reflection -> invokeArgs ( $ ordered_arguments ) ; } catch ( Exception $ exception ) { throw new InvalidArgumentException ( sprintf ( _ ( 'Failed to invoke function "%1$s". Reason: %2$s' ) , $ function , $ exception -> getMessage ( ) ) ) ; } }
Check the accepted arguments for a given function and pass associative array values in the right order .
31,865
public function index ( $ userId ) { $ user = User :: with ( 'phones' ) -> findOrFail ( $ userId ) ; $ this -> authorize ( 'view' , $ user ) ; return fractal ( $ user -> phones , new PhoneTransformer ( ) ) -> withResourceName ( 'userPhone' ) -> respond ( ) ; }
Produce a list of Phones related to a selected User
31,866
public function getCommit ( $ short = true , $ path = null ) { $ short = $ short ? 'h' : 'H' ; $ path = $ this -> resolvePath ( $ path ) ; $ process = new Process ( "git log --pretty=\"%$short\" -n1 HEAD" , $ path ) ; if ( 0 === $ process -> run ( ) ) { return trim ( $ process -> getOutput ( ) ) ; } throw GitException :: process ( $ process ) ; }
Returns the current Git commit hash .
31,867
public function getTag ( $ path = null ) { $ path = $ this -> resolvePath ( $ path ) ; $ process = new Process ( 'git describe --tags HEAD' , $ path ) ; if ( 0 === $ process -> run ( ) ) { return trim ( $ process -> getOutput ( ) ) ; } throw GitException :: process ( $ process ) ; }
Returns the current Git tag .
31,868
public function setDefaultPath ( $ path = null ) { if ( ( null !== $ path ) && ( false === is_dir ( $ path ) ) ) { throw new InvalidArgumentException ( sprintf ( 'The path "%s" is not a directory path or does not exist.' , $ path ) ) ; } $ this -> path = $ path ; }
Sets the default repository directory path .
31,869
private function resolvePath ( $ path = null ) { if ( null === $ path ) { if ( null === $ this -> path ) { throw new LogicException ( 'No default Git repository path set.' ) ; } $ path = $ this -> path ; } return $ path ; }
Resolves the Git repository path argument .
31,870
private function buildUri ( $ uri , $ params ) { $ parse_url = parse_url ( $ uri ) ; foreach ( $ params as $ k => $ v ) { if ( isset ( $ parse_url [ $ k ] ) ) { $ parse_url [ $ k ] .= "&" . http_build_query ( $ v ) ; } else { $ parse_url [ $ k ] = http_build_query ( $ v ) ; } } return ( ( isset ( $ parse_url [ "scheme" ] ) ) ? $ parse_url [ "scheme" ] . "://" : "" ) . ( ( isset ( $ parse_url [ "user" ] ) ) ? $ parse_url [ "user" ] . ( ( isset ( $ parse_url [ "pass" ] ) ) ? ":" . $ parse_url [ "pass" ] : "" ) . "@" : "" ) . ( ( isset ( $ parse_url [ "host" ] ) ) ? $ parse_url [ "host" ] : "" ) . ( ( isset ( $ parse_url [ "port" ] ) ) ? ":" . $ parse_url [ "port" ] : "" ) . ( ( isset ( $ parse_url [ "path" ] ) ) ? $ parse_url [ "path" ] : "" ) . ( ( isset ( $ parse_url [ "query" ] ) ) ? "?" . $ parse_url [ "query" ] : "" ) . ( ( isset ( $ parse_url [ "fragment" ] ) ) ? "#" . $ parse_url [ "fragment" ] : "" ) ; }
Build the absolute URI based on supplied URI and parameters .
31,871
private function validateRedirectUri ( $ inputUri , $ registeredUriString ) { if ( ! $ inputUri || ! $ registeredUriString ) { return false ; } $ registered_uris = explode ( ' ' , $ registeredUriString ) ; foreach ( $ registered_uris as $ registered_uri ) { if ( $ this -> config [ 'require_exact_redirect_uri' ] ) { if ( strcmp ( $ inputUri , $ registered_uri ) === 0 ) { return true ; } } else { if ( strcasecmp ( substr ( $ inputUri , 0 , strlen ( $ registered_uri ) ) , $ registered_uri ) === 0 ) { return true ; } } } return false ; }
Internal method for validating redirect URI supplied
31,872
public function load ( ) { $ c = $ this ; $ this [ 'api' ] = function ( $ c ) { $ api = new Api ( $ c ) ; $ api -> registerServices ( array ( 'Subbly\\Api\\Service\\CategoryService' , 'Subbly\\Api\\Service\\CartService' , 'Subbly\\Api\\Service\\OrderService' , 'Subbly\\Api\\Service\\OrderAddressService' , 'Subbly\\Api\\Service\\OrderProductService' , 'Subbly\\Api\\Service\\OrderTokenService' , 'Subbly\\Api\\Service\\ProductService' , 'Subbly\\Api\\Service\\ProductCategoryService' , 'Subbly\\Api\\Service\\ProductImageService' , 'Subbly\\Api\\Service\\SettingService' , 'Subbly\\Api\\Service\\StatsService' , 'Subbly\\Api\\Service\\UserService' , 'Subbly\\Api\\Service\\UserAddressService' , 'Subbly\\Api\\Service\\PaymentService' , ) ) ; $ api -> service ( 'subbly.setting' ) -> registerDefaultSettings ( __DIR__ . '/../Resources/configs/default_settings.yml' ) ; $ api -> service ( 'subbly.stats' ) -> registerDefaultStats ( __DIR__ . '/../Resources/configs/default_stats.yml' ) ; return $ api ; } ; $ this [ 'event_dispatcher' ] = function ( $ c ) { return new EventDispatcher ( ) ; } ; $ this [ 'media_resolver' ] = function ( $ c ) { return new MediaResolver ( $ c ) ; } ; $ this [ 'mailer' ] = function ( $ c ) { return ; } ; $ this [ 'event_dispatcher' ] -> fire ( 'subbly.container:loaded' ) ; }
Load services .
31,873
private function autocompleter ( ) { $ info = readline_info ( ) ; $ text = substr ( $ info [ 'line_buffer' ] , 0 , $ info [ 'end' ] ) ; if ( $ info [ 'point' ] !== $ info [ 'end' ] ) { return true ; } if ( false === strpos ( $ text , ' ' ) || ! $ text ) { $ commands = array_keys ( $ this -> application -> all ( ) ) ; $ commands [ ] = 'quit' ; $ commands [ ] = 'all' ; return $ commands ; } try { $ command = $ this -> application -> find ( substr ( $ text , 0 , strpos ( $ text , ' ' ) ) ) ; } catch ( \ Exception $ e ) { return true ; } $ list = array ( '--help' ) ; foreach ( $ command -> getDefinition ( ) -> getOptions ( ) as $ option ) { $ opt = '--' . $ option -> getName ( ) ; if ( ! in_array ( $ opt , $ list ) ) { $ list [ ] = $ opt ; } } return $ list ; }
Tries to return autocompletion for the current entered text .
31,874
protected function buildUrl ( ) { $ this -> url = $ this -> baseUrl . '?' . http_build_query ( [ 'secret' => $ this -> secretKey , 'response' => $ this -> response ] ) ; }
Build the api request url with query parameters .
31,875
protected function execute ( InputInterface $ input , OutputInterface $ output ) { ini_set ( 'memory_limit' , '1024M' ) ; $ reader = new OekobaudatReader ( ) ; $ this -> store ( 'contact' , $ reader , $ reader -> getContactList ( ) , $ output ) ; $ this -> store ( 'flow_property' , $ reader , $ reader -> getFlowPropertyList ( ) , $ output ) ; $ this -> store ( 'process' , $ reader , $ reader -> getProcessList ( ) , $ output ) ; $ this -> store ( 'source' , $ reader , $ reader -> getSourceList ( ) , $ output ) ; $ this -> store ( 'unit_group' , $ reader , $ reader -> getUnitGroupList ( ) , $ output ) ; $ this -> storeFlows ( $ reader , $ output ) ; $ this -> getContainer ( ) -> get ( 'beaast.oekobaudat.manager.contact' ) -> updateReferences ( ) ; $ this -> getContainer ( ) -> get ( 'beaast.oekobaudat.manager.flow' ) -> updateReferences ( ) ; $ this -> getContainer ( ) -> get ( 'beaast.oekobaudat.manager.flow_property' ) -> updateReferences ( ) ; $ this -> getContainer ( ) -> get ( 'beaast.oekobaudat.manager.process' ) -> updateReferences ( ) ; $ this -> getContainer ( ) -> get ( 'beaast.oekobaudat.manager.source' ) -> updateReferences ( ) ; $ this -> getContainer ( ) -> get ( 'beaast.oekobaudat.manager.unit_group' ) -> updateReferences ( ) ; return 0 ; }
Execute CLI command
31,876
protected function pushClosureNode ( \ Twig_Node $ blocks , \ Twig_Node_Expression $ variables , $ parentName , \ Twig_Node_Block $ previous = null ) { if ( null === $ previous ) { return ; } $ name = $ previous -> getAttribute ( 'name' ) ; $ reference = new SuperblockReference ( $ name , $ variables , [ ] , $ previous -> getTemplateLine ( ) , $ previous -> getNodeTag ( ) ) ; $ reference -> setAttribute ( 'is_closure' , true ) ; $ reference -> setAttribute ( 'parent_name' , $ parentName ) ; $ this -> parser -> setBlock ( $ name , $ previous ) ; $ blocks -> setNode ( \ count ( $ blocks ) , $ reference ) ; }
Push the previous twig node on new blocks body .
31,877
protected function getSforVariables ( \ Twig_TokenStream $ stream ) { $ forOptions = new \ Twig_Node_Expression_Array ( [ ] , $ stream -> getCurrent ( ) -> getLine ( ) ) ; $ this -> addKeyValues ( $ stream , $ forOptions ) ; $ sfor = $ forOptions -> getNode ( 1 ) -> getAttribute ( 'value' ) ; preg_match ( '/([\w\d\_]+) in ([\w\d\_\.\(\)\'\"]+)/' , $ sfor , $ matches ) ; if ( ! isset ( $ matches [ 1 ] ) || ! isset ( $ matches [ 2 ] ) ) { throw new \ Twig_Error_Syntax ( "The sfor parameter must be the pattern: '<variable> in <variables>'" , $ stream -> getCurrent ( ) -> getLine ( ) , $ stream -> getSourceContext ( ) -> getName ( ) ) ; } return [ $ matches [ 1 ] , $ this -> getSforInVariableNode ( $ matches [ 2 ] ) ] ; }
Get the variables defines in the Sfor attribute .
31,878
protected function getSforInVariableNode ( $ variable ) { $ env = new \ Twig_Environment ( new \ Twig_Loader_Array ( ) ) ; $ parser = new \ Twig_Parser ( $ env ) ; $ lexer = new \ Twig_Lexer ( $ env ) ; $ stream = $ lexer -> tokenize ( new \ Twig_Source ( '{{' . $ variable . '}}' , 'variables' ) ) ; return $ parser -> parse ( $ stream ) -> getNode ( 'body' ) -> getNode ( 0 ) -> getNode ( 'expr' ) -> getNode ( 'node' ) ; }
Get the in variable of sfor .
31,879
protected function addKeyValues ( \ Twig_TokenStream $ stream , \ Twig_Node_Expression_Array $ values ) { if ( ! $ stream -> test ( \ Twig_Token :: NAME_TYPE ) && ! $ stream -> test ( \ Twig_Token :: STRING_TYPE ) ) { throw new \ Twig_Error_Syntax ( sprintf ( 'The attribute name "%s" must be an STRING or CONSTANT' , $ stream -> getCurrent ( ) -> getValue ( ) ) , $ stream -> getCurrent ( ) -> getLine ( ) , $ stream -> getSourceContext ( ) -> getName ( ) ) ; } $ attr = $ stream -> getCurrent ( ) ; $ attr = new \ Twig_Node_Expression_Constant ( $ attr -> getValue ( ) , $ attr -> getLine ( ) ) ; $ stream -> next ( ) ; if ( ! $ stream -> test ( \ Twig_Token :: OPERATOR_TYPE , '=' ) ) { throw new \ Twig_Error_Syntax ( "The attribute must be followed by '=' operator" , $ stream -> getCurrent ( ) -> getLine ( ) , $ stream -> getSourceContext ( ) -> getName ( ) ) ; } $ stream -> next ( ) ; $ values -> addElement ( $ this -> parser -> getExpressionParser ( ) -> parseExpression ( ) , $ attr ) ; }
Add key with values in the array of values .
31,880
public function escape ( $ string ) { $ string = mb_convert_encoding ( $ string , 'UTF-8' , 'UTF-8' ) ; $ string = str_replace ( '{{' , '' , $ string ) ; $ string = str_replace ( '}}' , '' , $ string ) ; return htmlentities ( $ string , ENT_QUOTES , 'UTF-8' ) ; }
Escapes values from bad stuff but only simple .
31,881
protected function read ( ) { $ method = '__' . str_replace ( __CLASS__ . '::' , '' , __METHOD__ ) ; if ( $ this -> hasMethod ( $ method ) && is_callable ( [ $ this , $ method ] ) ) { $ arguments = func_get_args ( ) ; if ( empty ( $ arguments ) ) { $ result = $ this -> { $ method } ( ) ; } else { $ result = call_user_func_array ( [ $ this , $ method ] , $ arguments ) ; } return $ result ; } }
Read of cRud .
31,882
protected function getBreadcrumbByUrl ( $ url , $ home = 'Home' ) { $ nodes = explode ( '/' , $ url ) ; $ countNodes = count ( $ nodes ) ; $ breadcrumb = [ ] ; $ root = '' ; for ( $ i = 0 ; $ i < $ countNodes ; ++ $ i ) { $ node = ( $ i === 0 ) ? $ home : $ nodes [ $ i ] ; $ breadcrumb [ ] = [ 'href' => ( $ i === 0 ) ? '/' : ( $ root . '/' . $ node ) , 'text' => $ node , 'active' => ( $ i === ( $ countNodes - 1 ) ) , 'class' => ( $ i === ( $ countNodes - 1 ) ) ? 'active' : null , 'id' => ( $ i === ( $ countNodes - 1 ) ) ? 'breadcrumb' : null , ] ; $ root .= ( $ i > 0 ) ? ( '/' . $ node ) : '' ; } return $ breadcrumb ; }
Returns an array containing a flat structure for a breadcrumb navigation .
31,883
public static function createFromBase ( SymfonyUploadedFile $ file , $ test = false ) { return $ file instanceof static ? $ file : new static ( $ file -> getPathname ( ) , $ file -> getClientOriginalName ( ) , $ file -> getClientMimeType ( ) , $ file -> getClientSize ( ) , $ file -> getError ( ) , $ test ) ; }
Create a new file instance from a base instance .
31,884
public function get ( $ key , $ default = null ) { $ value = $ this -> raw ( $ key , $ default ) ; $ escape = $ this -> escape ; return $ escape ( $ value ) ; }
get an escaped value .
31,885
public function raw ( $ key , $ default = null ) { if ( strpos ( $ key , '[' ) === false ) { return Accessor :: get ( $ this -> data , $ key , $ default ) ; } $ found = $ this -> parseRaw ( $ key ) ; if ( ! is_null ( $ found ) ) { return $ found ; } return $ default ; }
get a raw value .
31,886
public function getName ( ) { $ name = $ this -> getNode ( ) -> nodeName ; if ( strpos ( $ name , ':' ) !== false ) { $ name = implode ( '' , array_slice ( explode ( ':' , $ name ) , - 1 , 1 ) ) ; } return $ name ; }
name without namespace
31,887
function setSegment ( $ pathOffset ) { if ( is_int ( $ pathOffset ) ) $ pathOffset = array ( $ pathOffset , null ) ; if ( ! is_array ( $ pathOffset ) && count ( $ pathOffset ) !== 2 ) throw new \ InvalidArgumentException ( sprintf ( 'Segment is an array [$offset, $length]; given: (%s).' , \ Poirot \ Std \ flatten ( $ pathOffset ) ) ) ; $ this -> pathOffset = $ pathOffset ; return $ this ; }
Set Path Offset To Match With Request Path Segment
31,888
public function getName ( ) { if ( ! isset ( $ this -> name ) ) { $ this -> name = $ this -> isApp ( ) ? '' : trim ( str_replace ( $ this -> basePath , '' , $ module [ 'basePath' ] ) , '\\/' ) ; } return $ this -> name ; }
get module name example home
31,889
public function getModules ( $ inited = false ) { if ( $ inited ) { $ instances = [ ] ; if ( $ this -> _modules ) foreach ( $ this -> _modules as $ v ) { $ instances [ ] = $ this -> getModule ( $ v ) ; } return $ instances ; } return $ this -> _modules ; }
get sub modules if param is true then return Module object array
31,890
protected function parseModuleAlias ( $ alias ) { return isset ( $ this -> _moduleAliases [ $ alias ] ) ? $ this -> _moduleAliases [ $ alias ] : $ alias ; }
parse alias return real name
31,891
public function hasModule ( $ name ) { $ name = $ this -> parseModuleAlias ( $ name ) ; return isset ( $ this -> _modules ) && in_array ( $ name , $ this -> _modules ) ; }
has named sub module
31,892
public function getModule ( $ name ) { $ name = $ this -> parseModuleAlias ( $ name ) ; $ uid = 'module.' . $ name ; if ( $ this -> hasModule ( $ name ) ) { return $ this -> get ( $ uid ) ; } else { $ basePath = rtrim ( $ this -> basePath , '\\/' ) . '/' . $ name ; if ( file_exists ( $ basePath ) ) { $ this -> setModule ( $ name , $ basePath ) ; return $ this -> get ( $ uid ) ; ; } } return null ; }
get sub module instance
31,893
public function setModule ( $ name , $ module = null ) { if ( ! $ module ) { $ module = $ name ; } if ( $ module instanceof Module ) { $ name = $ module -> getName ( ) ; $ alias = $ module -> alias ; } else { if ( is_string ( $ module ) ) { $ module = [ 'basePath' => $ module ] ; } elseif ( is_array ( $ module ) ) { if ( ! isset ( $ module [ 'basePath' ] ) ) { $ module [ 'basePath' ] = $ name ; } } else { throw new InvalidArgumentException ( 'modules config must be array.' ) ; } if ( strpos ( $ module [ 'basePath' ] , $ this -> basePath ) === false ) { $ module [ 'basePath' ] = rtrim ( $ this -> basePath , '/\\' ) . '/' . trim ( $ module [ 'basePath' ] , '/\\' ) . '/' ; } $ module [ 'class' ] = '\\Wslim\\Common\\Module' ; if ( is_numeric ( $ name ) ) { $ name = str_replace ( $ this -> basePath , '' , $ module [ 'basePath' ] ) ; } $ name = trim ( $ name , '\\/' ) ; $ module [ 'name' ] = $ name ; $ alias = isset ( $ module [ 'alias' ] ) ? $ module [ 'alias' ] : null ; } if ( ! isset ( $ this -> _modules ) ) { $ this -> _modules = [ ] ; } if ( $ alias ) { $ this -> _moduleAliases [ $ alias ] = $ name ; } if ( ! in_array ( $ name , $ this -> _modules ) ) { array_push ( $ this -> _modules , $ name ) ; $ uid = 'module.' . $ name ; $ this -> set ( $ uid , $ module ) ; } return $ this ; }
set sub module
31,894
protected function formatControllerName ( $ name ) { $ name = str_replace ( '..' , '.' , $ name ) ; $ name = str_replace ( './' , '' , $ name ) ; return DataHelper :: formatCode ( $ name ) ; }
format controller name
31,895
public function getView ( ) { if ( ! $ this -> has ( 'view' ) ) { $ configs = Config :: get ( 'views' , $ this -> getName ( ) , true ) ; if ( $ configs ) { $ client = ClientType :: detectClientType ( ) ; if ( $ client === ClientType :: PC ) { $ config = isset ( $ configs [ 'pc' ] ) ? $ configs [ 'pc' ] : [ ] ; } else { $ config = isset ( $ configs [ $ client ] ) ? $ configs [ $ client ] : ( isset ( $ configs [ 'mobile' ] ) ? $ configs [ 'mobile' ] : ( isset ( $ configs [ 'pc' ] ) ? $ configs [ 'pc' ] : [ ] ) ) ; } } else { $ config = Config :: get ( 'view' , $ this -> getName ( ) , true ) ; } if ( ! isset ( $ config [ 'templatePath' ] ) ) { $ config [ 'templatePath' ] = $ this -> basePath . 'view' ; } if ( ! isset ( $ config [ 'compiledPath' ] ) ) { $ config [ 'compiledPath' ] = rtrim ( Config :: getStoragePath ( ) , '/' ) . '/app/' . $ this -> getName ( ) . '/view' ; $ config [ 'compiledPath' ] = str_replace ( '//' , '/' , $ config [ 'compiledPath' ] ) ; } if ( ! isset ( $ config [ 'htmlPath' ] ) ) { $ config [ 'htmlPath' ] = rtrim ( Config :: getWebRootPath ( ) , '/' ) . '/html/' . $ this -> getName ( ) ; $ config [ 'htmlPath' ] = str_replace ( '//' , '/' , $ config [ 'htmlPath' ] ) ; } $ object = new View ( $ config ) ; $ this -> set ( 'view' , $ object ) ; } return $ this -> get ( 'view' ) ; }
get view instance
31,896
public function isValidTheme ( $ theme ) { $ path = str_replace ( '//' , '/' , $ this -> basePath . 'view/' . $ theme ) ; return file_exists ( $ path ) ? true : false ; }
is valid theme
31,897
public static function resetInstance ( ) : void { $ name = self :: $ instancePropertyName ; if ( is_object ( self :: $ $ name ) ) { if ( self :: $ $ name -> allowToResetInstance ) { self :: $ $ name = null ; } else { throw new \ RuntimeException ( "Resetting of singleton instance disallowed" ) ; } } }
Resets static instance .
31,898
public function onAuthenticationSuccess ( Request $ request , TokenInterface $ token ) { if ( $ request -> isXmlHttpRequest ( ) ) { $ result = array ( 'success' => true ) ; $ response = new JsonResponse ( $ result ) ; return $ response ; } }
This is called when an interactive authentication attempt succeeds .
31,899
protected function quoteIdentifier ( $ str ) { $ open = '"' ; $ close = '"' ; switch ( $ this -> pdoDriver ) { case 'mysql' : $ open = '`' ; $ close = '`' ; break ; case 'mssql' : $ open = '[' ; $ close = ']' ; break ; } return $ open . str_replace ( $ open , $ open . $ open , $ str ) . $ close ; }
Quotes the string as an identifier