idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
29,800 | protected function sqlStatementFlags ( $ buffer_id , $ flag_buffer_ids , $ decorations ) { $ first = false ; if ( $ decorations & self :: INDENT ) { echo $ this -> indent ; $ first = true ; } if ( $ decorations & self :: LABEL ) { if ( $ first ) { $ first = false ; } else { echo ' ' ; } echo $ buffer_id ; $ first = false ; } foreach ( $ flag_buffer_ids as $ flag_buf ) { if ( isset ( $ this -> buffers [ $ flag_buf ] ) ) { if ( $ first ) { $ first = false ; } else { echo ' ' ; } echo $ this -> buffers [ $ flag_buf ] ; } } if ( $ decorations & self :: COMMA ) { echo "," ; } if ( $ decorations & self :: EOL ) { echo "\n" ; } } | Generate SQL fragment made of flags . |
29,801 | protected function sqlList ( $ buffer_id , $ decorations ) { $ first = true ; if ( isset ( $ this -> buffers [ $ buffer_id ] ) ) { if ( $ decorations & ( self :: INDENT | self :: SUB_INDENT ) ) { if ( $ decorations & ( self :: BRACKETS | self :: SUB_INDENT ) ) { echo $ this -> sub_indent ; } else { echo $ this -> indent ; } } else if ( $ decorations & ( self :: LABEL | self :: BRACKETS ) ) { echo ' ' ; } if ( $ decorations & self :: LABEL ) { echo $ buffer_id ; } if ( $ decorations & self :: BRACKETS ) { echo '(' ; } foreach ( $ this -> buffers [ $ buffer_id ] as $ buf ) { if ( $ decorations & self :: NO_SEPARATOR ) { if ( $ first ) { $ first = false ; } else { echo "\n" , $ this -> sub_indent ; } } else if ( $ decorations & self :: BRACKETS ) { if ( $ first ) { $ first = false ; } else { echo ", " ; } } else { if ( $ first ) { $ first = false ; echo ' ' ; } else { echo ",\n" , $ this -> sub_indent ; } } $ this -> sqlBuffer ( $ buf ) ; } if ( $ decorations & self :: BRACKETS ) { echo ')' ; } if ( $ decorations & self :: COMMA ) { echo "," ; } if ( $ decorations & self :: EOL ) { echo "\n" ; } } } | Generate SQL fragment made of list . |
29,802 | protected function sqlValuesList ( $ buffer_id ) { $ first = true ; if ( isset ( $ this -> buffers [ $ buffer_id ] ) ) { echo $ this -> indent , $ buffer_id , "\n" ; foreach ( $ this -> buffers [ $ buffer_id ] as $ buf ) { if ( count ( $ buf ) == 1 ) { foreach ( $ buf [ 0 ] as $ row ) { if ( $ first ) { $ first = false ; echo $ this -> sub_indent , '(' ; } else { echo "),\n" , $ this -> sub_indent , '(' ; } echo join ( ', ' , array_map ( array ( $ this , 'quote' ) , $ row ) ) ; } } else { throw new \ Exception ( 'Not implemented yet.' ) ; } } echo ')' ; echo "\n" ; } } | Generate SQL fragment made of list values . |
29,803 | protected function sqlJoins ( $ buffer_id ) { $ first = true ; if ( isset ( $ this -> buffers [ $ buffer_id ] ) ) { foreach ( $ this -> buffers [ $ buffer_id ] as $ buf ) { $ join = array_pop ( $ buf ) ; echo $ this -> indent , $ join , " " , $ this -> sqlBuffer ( $ buf ) , "\n" ; } } } | Generate SQL fragment made of joins . |
29,804 | protected function sqlConditions ( $ buffer_id ) { $ first = true ; if ( isset ( $ this -> buffers [ $ buffer_id ] ) ) { echo $ this -> indent , $ buffer_id ; if ( $ this -> no_parenthesis_in_conditions ) { foreach ( $ this -> buffers [ $ buffer_id ] as $ buf ) { if ( $ first ) { $ first = false ; echo ' ' ; } else { echo $ this -> sub_indent , "AND " ; } echo $ this -> sqlBuffer ( $ buf ) , "\n" ; } } else { foreach ( $ this -> buffers [ $ buffer_id ] as $ buf ) { if ( $ first ) { $ first = false ; echo ' (' ; } else { echo $ this -> sub_indent , "AND (" ; } echo $ this -> sqlBuffer ( $ buf ) , ")\n" ; } } } } | Generate SQL fragment made of conditions in AND statement . |
29,805 | public function attach_volume ( $ volume_href , $ device ) { $ this -> executeCommand ( $ this -> _path_for_regex . '_attach_volume' , array ( 'id' => $ this -> id , 'server[ec2_ebs_volume_href]' => $ volume_href , 'server[device]' => $ device ) ) ; } | Attaches an EBS volume to the instance |
29,806 | public function current_settings ( ) { $ result = $ this -> executeCommand ( $ this -> _path_for_regex . '_current_settings' , array ( 'id' => $ this -> id ) ) ; $ json_str = $ result -> getBody ( true ) ; $ json_obj = json_decode ( $ json_str ) ; return $ json_obj ; } | Gets the settings for the current running server |
29,807 | public function current_show ( ) { $ result = $ this -> executeCommand ( $ this -> _path_for_regex . '_current_show' , array ( 'id' => $ this -> id ) ) ; return new Server ( $ result ) ; } | Gets the current running server |
29,808 | public function current_update ( $ params ) { $ result = $ this -> executeCommand ( $ this -> _path_for_regex . '_current_update' , array ( 'id' => $ this -> id , 'server[parameters]' => $ params ) ) ; return $ result -> getStatusCode ( ) == 204 ; } | Updates the current running servers input parameters |
29,809 | public function get_sketch_data ( $ start , $ end , $ variable = null , $ resolution = null , $ plugin_name = null , $ plugin_type = null ) { $ params = array ( 'id' => $ this -> id , 'start' => $ start , 'end' => $ end ) ; if ( $ variable ) { $ params [ 'variable' ] = $ variable ; } if ( $ resolution ) { $ params [ 'resolution' ] = $ resolution ; } if ( $ plugin_name ) { $ params [ 'plugin_name' ] = $ plugin_name ; } if ( $ plugin_type ) { $ params [ 'plugin_type' ] = $ plugin_type ; } $ result = $ this -> executeCommand ( $ this -> _path_for_regex . '_get_sketchy_data' , $ params ) ; $ json_str = $ result -> getBody ( true ) ; $ json_obj = json_decode ( $ json_str ) ; return $ json_obj ; } | Gets the raw monitoring data for the specified time period |
29,810 | public function monitoring_graph_name ( $ graph_name , $ size , $ period , $ tz , $ title ) { $ result = $ this -> executeCommand ( $ this -> _path_for_regex . '_monitoring_graph_name' , array ( 'id' => $ this -> id , 'graph_name' => $ graph_name , 'size' => $ size , 'period' => $ period , 'tz' => $ tz , 'title' => $ title ) ) ; $ json_str = $ result -> getBody ( true ) ; $ json_obj = json_decode ( $ json_str ) ; return $ json_obj -> href ; } | Gets a URL for one specific monitoring graph |
29,811 | public function reboot ( ) { $ result = $ this -> executeCommand ( $ this -> _path_for_regex . '_reboot' , array ( 'id' => $ this -> id ) ) ; return $ result -> getStatusCode ( ) == 200 ; } | Reboots the running server |
29,812 | public function run_executable ( $ right_script_href = null , $ recipe = null , $ params = null , $ ignore_lock = false ) { if ( ! $ right_script_href & ! $ recipe ) { throw new InvalidArgumentException ( "Either right_script_href or recipe must be specified" ) ; } $ parameters = array ( 'id' => $ this -> id , 'server[ignore_lock]' => $ ignore_lock ) ; if ( $ right_script_href ) { $ parameters [ 'server[right_script_href]' ] = $ right_script_href ; } if ( $ recipe ) { $ parameters [ 'server[recipe]' ] = $ recipe ; } if ( $ params ) { $ parameters [ 'server[parameters]' ] = $ params ; } $ this -> executeCommand ( $ this -> _path_for_regex . '_run_executable' , $ parameters ) ; } | Runs a RightScript or Recipe on the server |
29,813 | public function run_script ( $ right_script_href = null , $ params = null , $ ignore_lock = false ) { $ parameters = array ( 'id' => $ this -> id , 'server[ignore_lock]' => $ ignore_lock , 'server[right_script_href]' => $ right_script_href ) ; if ( $ params ) { $ parameters [ 'server[parameters]' ] = $ params ; } $ this -> executeCommand ( $ this -> _path_for_regex . '_run_script' , $ parameters ) ; } | Runs a RightScript on the server |
29,814 | public function start_ebs ( $ params = null ) { $ parameters = array ( 'id' => $ this -> id ) ; if ( $ params ) { $ parameters [ 'server[parameters]' ] = $ params ; } $ result = $ this -> executeCommand ( $ this -> _path_for_regex . '_start_ebs' , $ parameters ) ; } | Starts an EBS backed server that has been stopped |
29,815 | public function stop ( $ ignore_lock = false ) { $ parameters = array ( 'id' => $ this -> id , 'server[ignore_lock]' ) ; $ result = $ this -> executeCommand ( $ this -> _path_for_regex . '_stop' , $ parameters ) ; } | Terminates the server |
29,816 | private function _initPasswordMatrices ( ) { self :: $ _RANGE_USERFRIENDLY = $ this -> _matrixLexer ( self :: $ _RANGE_USERFRIENDLY ) ; self :: $ _RANGE_USERFRIENDLY_REMEMBER = $ this -> _matrixLexer ( self :: $ _RANGE_USERFRIENDLY_REMEMBER ) ; self :: $ _RANGE_ALPHANUM = $ this -> _matrixLexer ( self :: $ _RANGE_ALPHANUM ) ; self :: $ _RANGE_ALPHANUM_SPECIAL = $ this -> _matrixLexer ( self :: $ _RANGE_ALPHANUM_SPECIAL ) ; self :: $ _RANGE_ALPHANUM_SPECIAL_HARDCORE = $ this -> _matrixLexer ( self :: $ _RANGE_ALPHANUM_SPECIAL_HARDCORE ) ; } | initializes the password matrices and lex the syntax to usable chars . |
29,817 | private function _matrixLexer ( $ lexBase ) { foreach ( $ lexBase as $ area => $ content ) { if ( ! is_array ( $ content ) ) { $ charMatrix = explode ( ',' , $ content ) ; $ matrix = [ ] ; $ countCharMatrix = count ( $ charMatrix ) ; for ( $ i = 0 ; $ i < $ countCharMatrix ; ++ $ i ) { if ( stristr ( $ charMatrix [ $ i ] , '-' ) ) { $ tmp = explode ( '-' , $ charMatrix [ $ i ] ) ; ( $ tmp [ 0 ] > $ tmp [ 1 ] ) ? ( $ tmp [ 0 ] ^= $ tmp [ 1 ] ^= $ tmp [ 0 ] ^= $ tmp [ 1 ] ) : '' ; for ( $ j = $ tmp [ 0 ] ; $ j <= $ tmp [ 1 ] ; ++ $ j ) { $ matrix [ ] = chr ( ( int ) $ tmp [ 0 ] ) ; ++ $ tmp [ 0 ] ; } } else { $ matrix [ ] = chr ( ( int ) $ charMatrix [ $ i ] ) ; } } $ tmp = array_unique ( $ matrix ) ; $ matrix = [ ] ; foreach ( $ tmp as $ elem ) { $ matrix [ ] = $ elem ; } $ lexBase [ $ area ] = $ matrix ; } } return $ lexBase ; } | lexes a given array to usable char representation . |
29,818 | public function generate ( $ type = self :: PASSWORD_ALPHANUM_SPECIAL , $ length = 12 , $ returnType = self :: RETURN_TYPE_PLAIN ) { $ password = '' ; switch ( $ type ) { case self :: PASSWORD_ALPHANUM : for ( $ i = 0 ; $ i < $ length ; ++ $ i ) { $ password .= $ this -> getRandomCharacter ( self :: $ _RANGE_ALPHANUM [ 'default' ] ) ; } break ; case self :: PASSWORD_ALPHANUM_SPECIAL : for ( $ i = 0 ; $ i < $ length ; ++ $ i ) { $ password .= $ this -> getRandomCharacter ( self :: $ _RANGE_ALPHANUM_SPECIAL [ 'default' ] ) ; } break ; case self :: PASSWORD_ALPHANUM_SPECIAL_HARDCORE : for ( $ i = 0 ; $ i < $ length ; ++ $ i ) { $ password .= $ this -> getRandomCharacter ( self :: $ _RANGE_ALPHANUM_SPECIAL_HARDCORE [ 'default' ] ) ; } break ; case self :: PASSWORD_USERFRIENDLY : $ password = $ this -> _createUserFriendlyPassword ( self :: $ _RANGE_USERFRIENDLY , $ length ) ; break ; case self :: PASSWORD_USERFRIENDLY_REMEMBER : $ password = $ this -> _createUserFriendlyPassword ( self :: $ _RANGE_USERFRIENDLY_REMEMBER , $ length ) ; break ; } switch ( $ returnType ) { case self :: RETURN_TYPE_MD5 : $ password = $ this -> getMd5Hash ( $ password ) ; break ; case self :: RETURN_TYPE_PASSWORDHASH : $ password = $ this -> getPasswordhash ( $ password ) ; break ; } return $ password ; } | generates a random password . |
29,819 | private function _createUserFriendlyPassword ( $ base , $ length ) { $ password = '' ; if ( $ length % 2 > 0 ) { throw new Doozr_Exception ( 'Length of userfriendly-password must be a multiple of two!' ) ; } for ( $ i = 0 ; $ i < $ length ; ++ $ i ) { if ( ( ( $ i + 1 ) % 2 ) != 0 ) { $ password .= $ this -> getRandomCharacter ( $ base [ 'default' ] ) ; } else { $ password .= $ this -> getRandomCharacter ( $ base [ 'special' ] ) ; } } return $ password ; } | generates a userfriendly password . |
29,820 | private function _seed ( ) { list ( $ usec , $ sec ) = explode ( ' ' , microtime ( ) ) ; $ a = ( float ) $ sec + ( ( float ) $ usec * 100000 ) ; return ( float ) $ a + $ this -> config -> kernel -> security -> cryptography -> keys -> private ; } | returns a seed value for randomizer . |
29,821 | public function scoreDifference ( $ passwordOne = null , $ passwordTwo = null ) { if ( ! $ passwordOne ) { throw new Doozr_Exception ( 'Missing input parameter one: $passwordOne for calculating score!' ) ; } elseif ( ! $ passwordOne ) { throw new Doozr_Exception ( 'Missing input parameter two: $passwordTwo for calculating score!' ) ; } if ( $ passwordOne == $ passwordTwo ) { return 0 ; } pre ( $ this -> _getColognePhonetic ( $ passwordOne ) ) ; pre ( $ this -> _getColognePhonetic ( $ passwordTwo ) ) ; $ scoreDiffLength = abs ( strlen ( $ passwordOne ) - strlen ( $ passwordTwo ) ) ; $ scoreDiffAscii = abs ( $ this -> _asciiSum ( $ passwordOne ) - $ this -> _asciiSum ( $ passwordTwo ) ) / 1000 ; pred ( $ scoreDiffAscii ) ; } | calculates the score for the differences between two passwords . |
29,822 | private function _asciiSum ( $ string ) { $ sum = 0 ; $ chars = str_split ( $ string ) ; $ charCount = count ( $ chars ) ; for ( $ i = 0 ; $ i < $ charCount ; ++ $ i ) { $ sum += ord ( $ chars [ $ i ] ) ; } return $ sum ; } | calculates the sum of the ascii representation of a string . |
29,823 | public function validateAgainstHash ( $ buffer , $ hash ) { if ( null === self :: $ passwordHash ) { include_once DOOZR_DOCUMENT_ROOT . 'Service/Doozr/Password/Service/Lib/Hash.php' ; self :: $ passwordHash = new Doozr_Password_Service_Hash ( 8 , false ) ; } return self :: $ passwordHash -> CheckPassword ( $ buffer , $ hash ) ; } | validates a given password against a given hash . |
29,824 | public function hash ( $ buffer ) { if ( self :: $ passwordHash === null ) { include_once DOOZR_DOCUMENT_ROOT . 'Service/Doozr/Password/Service/Lib/Hash.php' ; self :: $ passwordHash = new Doozr_Password_Service_Hash ( 8 , false ) ; } return self :: $ passwordHash -> HashPassword ( $ buffer ) ; } | Returns the hash for a passed buffer . |
29,825 | protected function prepareParameters ( ReflectionMethod $ constructor , $ additionalParameters ) { $ parameters = array ( ) ; foreach ( $ constructor -> getParameters ( ) as $ parameter ) { $ parameterValue = null ; if ( isset ( $ additionalParameters [ $ parameter -> name ] ) ) { $ parameterValue = $ additionalParameters [ $ parameter -> name ] ; } else if ( $ parameter -> getClass ( ) !== null ) { $ parameterValue = $ this -> getInstance ( $ parameter -> getClass ( ) ) ; } if ( $ parameterValue === null ) { throw new Exception ( 'Cannot find correct value for parameter "' . $ parameter -> name . '" in class "' . $ constructor -> class . '".' ) ; } $ parameters [ ] = $ parameterValue ; } return $ parameters ; } | Prepares the parameters for the given constructor |
29,826 | protected function getInstance ( ReflectionClass $ parameterClass ) { if ( ! class_exists ( $ parameterClass -> name , true ) ) { return null ; } if ( strpos ( $ parameterClass -> name , 'Zepi\\Turbo\\' ) === 0 ) { return $ this -> getFrameworkInstance ( $ parameterClass ) ; } if ( $ parameterClass -> isInstantiable ( ) ) { return $ this -> framework -> getInstance ( $ parameterClass -> name ) ; } } | Returns the instance for the given class |
29,827 | protected function getFrameworkInstance ( ReflectionClass $ parameterClass ) { if ( $ parameterClass -> name == 'Zepi\\Turbo\\Framework' ) { return $ this -> framework ; } if ( $ parameterClass -> name == 'Zepi\\Turbo\\Request\\RequestAbstract' ) { return $ this -> framework -> getRequest ( ) ; } if ( $ parameterClass -> name == 'Zepi\\Turbo\\Response\\Response' ) { return $ this -> framework -> getResponse ( ) ; } if ( $ parameterClass -> getNamespaceName ( ) === 'Zepi\\Turbo\\Manager' ) { return $ this -> getFrameworkManager ( $ parameterClass -> name ) ; } } | Returns the instance for the given class if the class path starts with Zepi \ Turbo . |
29,828 | protected function getFrameworkManager ( $ className ) { switch ( $ className ) { case 'Zepi\\Turbo\\Manager\\DataSourceManager' : return $ this -> framework -> getDataSourceManager ( ) ; break ; case 'Zepi\\Turbo\\Manager\\DependencyInjectionManager' : return $ this -> framework -> getDependencyInjectionManager ( ) ; break ; case 'Zepi\\Turbo\\Manager\\ModuleManager' : return $ this -> framework -> getModuleManager ( ) ; break ; case 'Zepi\\Turbo\\Manager\\RequestManager' : return $ this -> framework -> getRequestManager ( ) ; break ; case 'Zepi\\Turbo\\Manager\\RouteManager' : return $ this -> framework -> getRouteManager ( ) ; break ; case 'Zepi\\Turbo\\Manager\\RuntimeManager' : return $ this -> framework -> getRuntimeManager ( ) ; break ; default : throw new Exception ( 'Cannot find framework manager "' . $ className . '".' ) ; break ; } } | Returns the framework manager for the given class name |
29,829 | public function getField ( $ type ) { return ! isset ( $ this -> fields [ $ type ] ) ? null : new ParamBag ( $ this -> fields [ $ type ] ) ; } | Get field params for the specified type . |
29,830 | public function handleConnection ( $ socket ) { stream_set_blocking ( $ socket , 0 ) ; $ client = $ this -> createConnection ( $ socket ) ; $ timer = $ this -> loop -> addTimer ( 5 , function ( ) use ( $ client ) { $ client -> removeAllListeners ( 'init' ) ; $ client -> end ( 'Timeout waiting for PROXY header.' ) ; $ this -> emit ( 'proxytimeout' , [ new Connection ( $ client -> stream , $ this -> loop ) ] ) ; } ) ; $ client -> on ( 'init' , function ( $ connection ) use ( $ client , $ timer ) { $ timer -> cancel ( ) ; $ this -> emit ( 'connection' , [ $ connection ] ) ; } ) ; } | Handle the connection . We only emit the connection event after the proper header was received . |
29,831 | protected function _set ( $ key , $ value , $ ttl = null ) { if ( $ ttl !== null ) { $ ttl = $ this -> _normalizeInt ( $ ttl ) ; } try { $ this -> _setData ( $ key , $ value ) ; } catch ( RootException $ e ) { if ( $ e instanceof InvalidArgumentException ) { throw $ e ; } throw $ this -> _createContainerException ( $ this -> __ ( 'Could not set data' ) , null , $ e , $ this ) ; } } | Sets a value for the specified key . |
29,832 | public function load ( $ className ) { $ currentNamespace = $ this -> namespace . $ this -> namespaceSeparator ; $ namespace = substr ( $ className , 0 , strlen ( $ currentNamespace ) ) ; if ( $ this -> namespace === null || $ currentNamespace === $ namespace ) { $ filename = '' ; $ lastNamespaceSeparatorPosition = strripos ( $ className , $ this -> namespaceSeparator ) ; if ( $ lastNamespaceSeparatorPosition !== false ) { $ namespace = substr ( $ className , 0 , $ lastNamespaceSeparatorPosition ) ; $ className = substr ( $ className , $ lastNamespaceSeparatorPosition + 1 ) ; $ filename = str_replace ( $ this -> namespaceSeparator , $ this -> separator , $ namespace ) . $ this -> separator ; } $ filename .= str_replace ( '_' , $ this -> separator , $ className ) . '.php' ; $ path = $ this -> getPath ( ) ; if ( $ path !== null ) { foreach ( $ path as $ singlePath ) { $ filename = $ singlePath . $ this -> separator . $ filename ; if ( file_exists ( $ filename ) ) { include_once $ filename ; return true ; } } } } return false ; } | This method is the loader mechanism for this loader configuration |
29,833 | public function query ( $ xpath , $ flags = 0 ) { $ nodes = $ this -> getXPath ( ) -> query ( $ xpath , $ this -> getDomElement ( ) ) ; if ( 0 === $ nodes -> length && $ flags & self :: REQUIRED ) { throw new MalformedNodeException ( sprintf ( 'Required node (%s) not found' , $ xpath ) ) ; } if ( $ flags & self :: SINGLE ) { if ( $ nodes -> length > 1 ) { throw new MalformedNodeException ( sprintf ( '%s must not contain more than one %s node' , $ this -> getDomElement ( ) -> localName , $ xpath ) ) ; } elseif ( $ nodes -> length === 0 ) { return null ; } return $ nodes -> item ( 0 ) ; } return $ nodes ; } | Return child DOM element by name . |
29,834 | public function getAttribute ( $ attrName ) { $ element = $ this -> getDomElement ( ) ; if ( strpos ( $ attrName , ':' ) === false ) { return $ element -> hasAttribute ( $ attrName ) ? $ element -> getAttribute ( $ attrName ) : null ; } else { list ( $ prefix , $ name ) = explode ( ':' , $ attrName ) ; $ namespace = $ this -> getNamespace ( $ prefix ) ; return $ element -> hasAttributeNS ( $ namespace , $ name ) ? $ element -> getAttributeNS ( $ namespace , $ name ) : null ; } } | Get attribute value . |
29,835 | protected function addChild ( $ name , $ cacheId ) { $ child = $ this -> getExtensions ( ) -> createElement ( $ this , $ name ) ; $ this -> dropCachedProperty ( $ cacheId ) ; return $ child ; } | Add new child element |
29,836 | protected function getXPath ( ) { if ( ! $ this -> xpath ) { $ this -> xpath = new \ DOMXPath ( $ this -> getDomElement ( ) -> ownerDocument ) ; $ namespaces = $ this -> getExtensions ( ) -> getNamespaces ( ) ; foreach ( $ namespaces as $ prefix => $ namespace ) { $ this -> xpath -> registerNamespace ( $ prefix , $ namespace ) ; } } return $ this -> xpath ; } | Get the XPath query object |
29,837 | private function getNamespace ( $ prefix ) { $ namespaces = $ this -> getExtensions ( ) -> getNamespaces ( ) ; if ( ! array_key_exists ( $ prefix , $ namespaces ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Unknown NS prefix "%s"' , $ prefix ) ) ; } return $ namespaces [ $ prefix ] ; } | Return namespace by registered prefix . |
29,838 | public function createWSDL ( $ force = false ) { $ filename = $ this -> wsdl_path ; if ( ! file_exists ( $ filename ) || $ force ) { $ dir = dirname ( $ filename ) ; if ( ! file_exists ( $ dir ) ) { $ res = mkdir ( $ dir , '0755' , true ) ; if ( ! $ res ) { echo 'create dir failure:' . $ dir ; exit ; } } $ str = $ this -> getWSDL ( ) ; if ( ! $ len = file_put_contents ( $ filename , $ str ) ) { return false ; } } return $ this -> wsdl_url ; } | create wsdl file |
29,839 | public function render ( ? Request $ request = null ) : Response { $ request = self :: validateRequest ( $ request ) ; $ translator = $ this -> translatorProvider -> getPreferredTranslator ( $ request -> getLanguages ( ) , $ this -> config [ 'default_language' ] ) ; $ response = new Response ( ) ; $ response -> setContent ( $ this -> templateRenderer -> render ( $ this -> config [ 'template_name' ] , array_merge ( $ translator -> getTranslations ( ) , [ 'lang' => $ translator -> getLanguage ( ) , 'charset' => $ this -> config [ 'charset' ] ] ) ) . "\n<!-- Powered by progminer/maintenance-screen (https://packagist.org/packages/progminer/maintenance-screen) ) ; $ response -> headers -> set ( 'Content-Language' , $ translator -> translate ( 'lang' ) ) ; return $ response ; } | Renders maintenance screen for Request to Response |
29,840 | public function send ( ? Request $ request = null ) { $ request = self :: validateRequest ( $ request ) ; $ this -> render ( $ request ) -> prepare ( $ request ) -> send ( ) ; } | Renders and sends maintenance screen for Request |
29,841 | public function addListenerId ( $ listenerId ) { if ( null !== $ this -> getListenerId ( $ listenerId ) ) { return ; } $ this -> listeners [ $ listenerId ] = $ listenerId ; } | Adds the listener id to the collections |
29,842 | public function getListenerId ( $ listenerId ) { return ( array_key_exists ( $ listenerId , $ this -> listeners ) ) ? $ this -> listeners [ $ listenerId ] : null ; } | Returns the listener id |
29,843 | public static function getInstance ( string $ dumper ) : AbstractDumper { $ class = static :: getClassName ( $ dumper ) ; if ( ! isset ( static :: $ singletons [ $ class ] ) ) { static :: $ singletons [ $ class ] = new $ class ( ) ; } return static :: $ singletons [ $ class ] ; } | Get the dumper instance . |
29,844 | public function run ( $ data , $ id = null ) { $ this -> hr ( ) ; $ this -> out ( __d ( 'cake_ldap' , 'CakePHP Queue Order task.' ) ) ; $ queueLength = $ this -> ExtendQueuedTask -> getLengthQueue ( 'OrderEmployee' ) ; if ( $ queueLength > 0 ) { $ this -> out ( __d ( 'cake_ldap' , 'Found order task in queue: %d. Skipped.' , $ queueLength ) ) ; return true ; } $ this -> QueuedTask -> updateProgress ( $ id , 0 ) ; if ( $ this -> SubordinateDb -> verify ( ) !== true ) { $ this -> err ( __d ( 'cake_ldap' , 'Tree of employees is broken. Perform a restore.' ) ) ; $ this -> QueuedTask -> markJobFailed ( $ id , __d ( 'cake_ldap' , 'Tree of employees is broken. Perform a restore.' ) ) ; return true ; } $ this -> QueuedTask -> updateProgress ( $ id , 0.5 ) ; $ result = $ this -> SubordinateDb -> reorderEmployeeTree ( false ) ; if ( ! $ result ) { $ this -> QueuedTask -> markJobFailed ( $ id , __d ( 'cake_ldap' , 'Error on reorder tree of employee.' ) ) ; } $ this -> QueuedTask -> updateProgress ( $ id , 1 ) ; return true ; } | Main function . Used for order tree of employee . |
29,845 | public function validateKey ( ) { try { $ this -> api -> get ( '' ) ; } catch ( \ Exception $ e ) { if ( starts_with ( $ e -> getMessage ( ) , '{' ) ) { $ json = json_decode ( $ e -> getMessage ( ) ) ; if ( $ json -> status == 401 ) { throw new InvalidApiKey ( $ json -> detail ) ; } } throw $ e ; } } | Determine if an API key is valid |
29,846 | public function feedAction ( $ _format ) { $ format = $ _format == 'xml' ? 'rss' : $ _format ; $ articles = $ this -> get ( 'vince_cms.repository.article' ) -> findAllPublishedIndexableOrdered ( ) ; return $ this -> render ( sprintf ( 'VinceCmsBundle:Templates:feed.%s.twig' , $ format ) , array ( 'articles' => $ articles , 'id' => sha1 ( $ this -> get ( 'router' ) -> generate ( 'cms_feed' , array ( '_format' => $ format ) , true ) ) , ) ) ; } | Display feed with all published Articles ordered by start publication date |
29,847 | public function showAction ( Request $ request ) { $ article = $ this -> getDoctrine ( ) -> getRepository ( $ this -> container -> getParameter ( 'vince_cms.class.article' ) ) -> find ( $ request -> attributes -> get ( '_id' ) ) ; if ( ! $ article || ( ! $ article -> isPublished ( ) && ! $ this -> get ( 'security.context' ) -> isGranted ( 'ROLE_ADMIN' ) ) ) { throw $ this -> createNotFoundException ( ) ; } $ options = $ this -> get ( 'event_dispatcher' ) -> dispatch ( 'vince_cms.event.load' , new CmsEvent ( $ article , array ( 'request' => $ request ) ) ) -> getOptions ( ) ; $ options = $ this -> get ( 'event_dispatcher' ) -> dispatch ( sprintf ( 'vince_cms.event.load.%s' , $ article -> getSlug ( ) ) , new CmsEvent ( $ article , $ options ) ) -> getOptions ( ) ; $ options = $ this -> get ( 'event_dispatcher' ) -> dispatch ( sprintf ( 'vince_cms.event.load.template.%s' , $ article -> getTemplate ( ) -> getSlug ( ) ) , new CmsEvent ( $ article , $ options ) ) -> getOptions ( ) ; if ( $ response = $ this -> get ( 'vince_cms.form.handler' ) -> process ( $ request , $ options ) ) { return $ response ; } return $ this -> render ( $ article -> getTemplate ( ) -> getPath ( ) , $ options ) -> setStatusCode ( $ request -> isMethod ( 'post' ) ? 400 : 200 ) ; } | Show an article |
29,848 | public function fetch ( $ return = false ) { switch ( $ this -> library ) { case 'phptal' : try { $ buffer = $ this -> execute ( ) ; if ( $ return === true ) { return $ buffer ; } else { echo $ buffer ; } } catch ( Exception $ e ) { throw new Doozr_Exception ( $ e ) ; } break ; } return null ; } | Fetches and optional returns the processed template for further processing |
29,849 | public function assignVariable ( $ variable = null , $ value = null ) { switch ( $ this -> library ) { case 'phptal' : return ( $ this -> { $ variable } = $ value ) ; break ; default : return false ; } } | Assigns a variable to the template instance |
29,850 | public function assignVariables ( array $ variables ) { $ result = count ( $ variables ) ? true : false ; foreach ( $ variables as $ variable => $ value ) { $ result = ( $ result && $ this -> assignVariable ( $ variable , $ value ) ) ; } return $ result ; } | method to assign more than one variable at once |
29,851 | public function getName ( ) { if ( $ this -> name === null ) { $ class = get_called_class ( ) ; if ( preg_match ( '/_+(.+)_+/' , $ class , $ matches ) > 0 ) { $ this -> name = $ matches [ 1 ] ; } else { $ this -> name = '' ; } } return $ this -> name ; } | Returns the name of the service |
29,852 | public function viewWithPayload ( ) { return function ( string $ view , PayloadContract $ payload , string $ key = 'payload' ) { return ResponseFactory :: view ( $ view , [ $ key => $ payload -> getUnwrappedOutput ( ) ] , $ payload -> getStatus ( ) ) ; } ; } | Response macro to send a response based on a payload . |
29,853 | public function getId ( ) { return sprintf ( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x' , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0x0fff ) | 0x4000 , mt_rand ( 0 , 0x3fff ) | 0x8000 , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) ) ; } | This implementation of UUID generation is based on code from a note made on the PHP documentation . |
29,854 | protected function getRoutes ( $ method = null , array $ routes = [ ] ) { if ( null !== $ method ) { if ( false === isset ( $ routes [ $ method ] ) ) { throw new Doozr_Route_Exception ( sprintf ( 'No routes for HTTP-method "%s" found.' , $ method ) , Doozr_Http :: METHOD_NOT_ALLOWED ) ; } $ routes = $ routes [ $ method ] ; } return $ routes ; } | Getter for routes . |
29,855 | protected function store ( array $ routes = [ ] ) { $ cache = $ this -> getRegistry ( ) -> getCache ( ) ; if ( $ cache instanceof Doozr_Cache_Service ) { $ cache -> create ( $ this -> getUuid ( ) , $ routes , null , $ this -> getScope ( ) ) ; } else { $ item = new CacheItem ( $ this -> getUuid ( ) ) ; $ item -> set ( $ routes ) ; $ cache -> save ( $ item ) ; } } | Stores routes in cache . |
29,856 | protected function restore ( $ uuid , $ scope = null ) { $ cache = $ this -> getRegistry ( ) -> getCache ( ) ; if ( $ cache instanceof Doozr_Cache_Service ) { $ routes = $ cache -> read ( $ uuid , $ scope ) ; } else { $ routes = $ cache -> getItem ( $ uuid ) ; $ routes = $ routes -> get ( ) ; } return $ routes ; } | Restores stored routes from cache . |
29,857 | protected function calculateUuid ( $ input ) { try { $ uuid5 = Uuid :: uuid5 ( Uuid :: NAMESPACE_DNS , $ input ) ; $ uuid = $ uuid5 -> toString ( ) ; } catch ( UnsatisfiedDependencyException $ e ) { $ uuid = sha1 ( $ input ) ; } return $ uuid ; } | Calculates a UUID for a passed string . |
29,858 | protected function parseRoutesFromFile ( $ filename ) { $ routes = [ ] ; $ actionsWithRoutes = [ ] ; if ( true === $ this -> getRegistry ( ) -> getFilesystem ( ) -> readable ( $ filename ) ) { include $ filename ; $ content = file_get_contents ( $ filename ) ; $ matches = preg_match ( '/class\s([A-Za-z\_]+)/' , $ content , $ classes ) ; if ( $ matches > 0 ) { $ className = $ classes [ 1 ] ; $ namespaceCount = preg_match ( '#^namespace\s+(.+?);$#sm' , $ content , $ namespace ) ; if ( $ namespaceCount > 0 ) { $ namespace = $ namespace [ 1 ] . '\\' ; } else { $ namespace = '' ; } $ fullQualifiedClassName = $ namespace . $ className ; $ reflection = new ReflectionClass ( $ fullQualifiedClassName ) ; $ methods = $ reflection -> getMethods ( ReflectionMethod :: IS_PUBLIC ) ; foreach ( $ methods as $ key => $ reflection ) { if ( preg_match ( '/(Action)$/ui' , $ reflection -> name ) ) { if ( isset ( $ actionsWithRoutes [ $ filename ] ) === false ) { $ actionsWithRoutes [ $ filename ] = [ ] ; } $ actionsWithRoutes [ $ filename ] [ $ reflection -> name ] = $ this -> getAnnotationReader ( ) -> getMethodAnnotations ( $ reflection ) ; } } } $ routes = $ this -> sortRoutes ( $ actionsWithRoutes ) ; } return $ routes ; } | Parses the routes from filename . |
29,859 | protected function getRoutesFromConfiguration ( array $ configuration ) { $ routes = [ ] ; foreach ( $ configuration as $ route => $ config ) { if ( isset ( $ config -> methods ) && null !== $ config -> methods ) { $ methods = explode ( ',' , $ config -> methods ) ; } else { $ methods = [ Doozr_Http :: REQUEST_METHOD_GET ] ; } foreach ( $ methods as $ method ) { if ( false === isset ( $ routes [ $ method ] ) ) { $ routes [ $ method ] = [ ] ; } $ config -> route = $ route ; $ routes [ $ method ] [ $ route ] = $ config ; } } return $ routes ; } | Retrieves routes from configuration in same format as from presenters . |
29,860 | protected function buildRoutingProfile ( $ node1 = null , $ node2 = null ) { return [ ( $ node1 !== null ) ? $ node1 : self :: DEFAULT_PRESENTER , ( $ node2 !== null ) ? $ node2 : self :: DEFAULT_ACTION , ] ; } | Takes two optional arguments and build a basic routing profile . If null is passed the default value is used . |
29,861 | public function getRepositoryFilter ( ) { if ( null === $ this -> repositoryFilter ) { $ this -> setRepositoryFilter ( new RepositoryFilter ( $ this ) ) ; } return $ this -> repositoryFilter ; } | Get repository filter |
29,862 | protected function getModelShortName ( ) { if ( ! $ this -> _modelShortName ) { $ m = explode ( '\\' , $ this -> modelClass ) ; $ this -> _modelShortName = $ m [ count ( $ m ) - 1 ] ; } return $ this -> _modelShortName ; } | Removes namespace from model class name ; |
29,863 | public static function normalize ( $ path , $ prependDrive = true ) { $ path = self :: join ( ( string ) $ path ) ; if ( $ prependDrive && $ path [ 0 ] === DIRECTORY_SEPARATOR ) { return strstr ( getcwd ( ) , DIRECTORY_SEPARATOR , true ) . $ path ; } return $ path ; } | Normalizes the provided file system path . |
29,864 | public static function join ( $ paths ) { $ joins = array_map ( 'strval' , is_array ( $ paths ) ? $ paths : func_get_args ( ) ) ; $ parts = self :: getParts ( $ joins ) ; $ absolute = self :: isAbsolute ( $ joins [ 0 ] ) ; $ root = $ absolute ? array_shift ( $ parts ) . DIRECTORY_SEPARATOR : '' ; $ parts = self :: resolve ( $ parts , $ absolute ) ; return self :: buildPath ( $ root , $ parts ) ; } | Joins the provided file systems paths together and normalizes the result . |
29,865 | private static function buildPath ( $ root , array $ parts ) { if ( $ parts === [ ] ) { return $ root === '' ? '.' : $ root ; } return $ root . implode ( DIRECTORY_SEPARATOR , $ parts ) ; } | Builds the final path from the root and path parts . |
29,866 | private static function isAbsolute ( $ path ) { $ path = trim ( $ path ) ; if ( $ path === '' ) { return false ; } $ length = strcspn ( $ path , '/\\' ) ; return $ length === 0 || $ path [ $ length - 1 ] === ':' ; } | Tells if the path is an absolute path . |
29,867 | private static function resolve ( array $ parts , $ absolute ) { $ resolved = [ ] ; foreach ( $ parts as $ path ) { if ( $ path === '..' ) { self :: resolveParent ( $ resolved , $ absolute ) ; } elseif ( self :: isValidPath ( $ path ) ) { $ resolved [ ] = $ path ; } } return $ resolved ; } | Resolves parent directory references and removes redundant entries . |
29,868 | private static function resolveParent ( array & $ parts , $ absolute ) { $ count = count ( $ parts ) ; if ( $ absolute || ( $ count > 0 && $ parts [ $ count - 1 ] !== '..' ) ) { array_pop ( $ parts ) ; return ; } $ parts [ ] = '..' ; } | Resolves the relative parent directory for the path . |
29,869 | public function toolModalCodeContainerAction ( ) { $ id = $ this -> params ( ) -> fromRoute ( 'id' , $ this -> params ( ) -> fromQuery ( 'id' , '' ) ) ; $ melisKey = $ this -> getMelisKey ( ) ; $ view = new ViewModel ( ) ; $ view -> setTerminal ( false ) ; $ view -> melisKey = $ melisKey ; $ view -> id = $ id ; return $ view ; } | Modal container for theme code form |
29,870 | public function saveItemAction ( ) { $ success = 0 ; $ message = 'tr_melis_cms_prospects_theme_items_save_failed' ; $ errors = [ ] ; $ title = 'tr_melis_cms_prospects_theme_items' ; $ request = $ this -> getRequest ( ) ; $ itemId = null ; $ inputValidator = 0 ; if ( $ request -> isPost ( ) ) { $ forms = $ this -> tool ( ) -> sanitizeRecursive ( get_object_vars ( $ request -> getPost ( ) ) , [ "'" , '"' ] , false ) ; $ themeId = $ forms [ 'themeId' ] ; if ( isset ( $ forms [ 'forms' ] ) && ! empty ( $ forms [ 'forms' ] ) ) { foreach ( $ forms [ 'forms' ] as $ idx => $ form ) { $ itemId = empty ( $ itemId ) ? ( int ) $ form [ 'item_trans_theme_item_id' ] : $ itemId ; $ itemTexts = empty ( $ itemTexts ) ? $ form [ 'item_trans_text' ] : $ itemTexts ; if ( ! empty ( $ form [ 'item_trans_text' ] ) || $ form [ 'item_trans_text' ] != "" ) $ inputValidator ++ ; } if ( $ inputValidator ) { if ( empty ( $ itemId ) && ! empty ( $ itemTexts ) ) { $ itemId = $ this -> themeItemTable ( ) -> save ( array ( 'pros_theme_id' => $ themeId ) ) ; } foreach ( $ forms [ 'forms' ] as $ idx => $ form ) { $ transId = isset ( $ form [ 'item_trans_id' ] ) ? ( int ) $ form [ 'item_trans_id' ] : null ; $ text = $ form [ 'item_trans_text' ] ; if ( ! empty ( $ transId ) && empty ( $ text ) ) { $ this -> themeItemTransTable ( ) -> deleteById ( $ transId ) ; } if ( ! empty ( $ itemId ) && ! empty ( $ text ) ) { $ form [ 'item_trans_theme_item_id' ] = $ itemId ; unset ( $ form [ 'item_trans_id' ] ) ; $ this -> themeItemTransTable ( ) -> save ( $ form , $ transId ) ; } } $ success = 1 ; $ message = 'tr_melis_cms_prospects_theme_items_save_success' ; } else { $ success = 0 ; $ errors [ $ this -> tool ( ) -> getTranslation ( "tr_melis_cms_prospects_theme_items_pros_theme_item_text2" ) ] [ "isEmpty" ] = $ this -> tool ( ) -> getTranslation ( "tr_melis_cms_prospects_theme_items_trans_text_empty" ) ; } } } $ response = [ 'success' => $ success , 'errors' => $ errors , 'textMessage' => $ this -> tool ( ) -> getTranslation ( $ message ) , 'textTitle' => $ this -> tool ( ) -> getTranslation ( $ title ) ] ; $ this -> getEventManager ( ) -> trigger ( 'meliscmsprospects_theme_item_save_end' , $ this , array_merge ( $ response , array ( 'typeCode' => 'CMS_PROSPECTS_THEME_ITEM_SAVE' , 'itemId' => $ itemId ) ) ) ; return new JsonModel ( $ response ) ; } | Saving method for theme items |
29,871 | public function get ( $ key ) { if ( ! $ this -> _isDataAvailable ( $ key ) ) { throw new \ Exception ( 'AVObject has no data for this key. Call fetch() to get the data.' ) ; } if ( isset ( $ this -> estimatedData [ $ key ] ) ) { return $ this -> estimatedData [ $ key ] ; } return null ; } | Get current value for an object property . |
29,872 | public function set ( $ key , $ value ) { if ( ! $ key ) { throw new Exception ( 'key may not be null.' ) ; } if ( is_array ( $ value ) ) { throw new Exception ( 'Must use setArray() or setAssociativeArray() for this value.' ) ; } $ this -> _performOperation ( $ key , new SetOperation ( $ value ) ) ; } | Validate and set a value for an object key . |
29,873 | public function setArray ( $ key , $ value ) { if ( ! $ key ) { throw new Exception ( 'key may not be null.' ) ; } if ( ! is_array ( $ value ) ) { throw new Exception ( 'Must use set() for non-array values.' ) ; } $ this -> _performOperation ( $ key , new SetOperation ( $ value ) ) ; } | Set an array value for an object key . |
29,874 | public function setAssociativeArray ( $ key , $ value ) { if ( ! $ key ) { throw new Exception ( 'key may not be null.' ) ; } if ( ! is_array ( $ value ) ) { throw new Exception ( 'Must use set() for non-array values.' ) ; } $ this -> _performOperation ( $ key , new SetOperation ( $ value , true ) ) ; } | Set an associative array value for an object key . |
29,875 | public function remove ( $ key , $ value ) { if ( ! $ key ) { throw new Exception ( 'key may not be null.' ) ; } if ( ! is_array ( $ value ) ) { $ value = [ $ value ] ; } $ this -> _performOperation ( $ key , new RemoveOperation ( $ value ) ) ; } | Remove a value from an array for an object key . |
29,876 | public function _performOperation ( $ key , FieldOperation $ operation ) { $ oldValue = null ; if ( isset ( $ this -> estimatedData [ $ key ] ) ) { $ oldValue = $ this -> estimatedData [ $ key ] ; } $ newValue = $ operation -> _apply ( $ oldValue , $ this , $ key ) ; if ( $ newValue !== null ) { $ this -> estimatedData [ $ key ] = $ newValue ; } else if ( isset ( $ this -> estimatedData [ $ key ] ) ) { unset ( $ this -> estimatedData [ $ key ] ) ; } if ( isset ( $ this -> operationSet [ $ key ] ) ) { $ oldOperations = $ this -> operationSet [ $ key ] ; $ newOperations = $ operation -> _mergeWithPrevious ( $ oldOperations ) ; $ this -> operationSet [ $ key ] = $ newOperations ; } else { $ this -> operationSet [ $ key ] = $ operation ; } $ this -> dataAvailability [ $ key ] = true ; } | Perform an operation on an object property . |
29,877 | public static function create ( $ className , $ objectId = null , $ isPointer = false ) { if ( isset ( self :: $ registeredSubclasses [ $ className ] ) ) { return new self :: $ registeredSubclasses [ $ className ] ( $ className , $ objectId , $ isPointer ) ; } else { return new AVObject ( $ className , $ objectId , $ isPointer ) ; } } | Static method which returns a new Avos Object for a given class Optionally creates a pointer object if the objectId is provided . |
29,878 | public function fetch ( ) { $ sessionToken = null ; if ( AVUser :: getCurrentUser ( ) ) { $ sessionToken = AVUser :: getCurrentUser ( ) -> getSessionToken ( ) ; } $ response = AVClient :: _request ( 'GET' , '/classes/' . $ this -> className . '/' . $ this -> objectId , $ sessionToken ) ; $ this -> _mergeAfterFetch ( $ response ) ; } | Fetch the whole object from the server and update the local object . |
29,879 | public function _mergeAfterFetchWithSelectedKeys ( $ result , $ selectedKeys ) { $ this -> _mergeAfterFetch ( $ result , $ selectedKeys ? empty ( $ selectedKeys ) : true ) ; foreach ( $ selectedKeys as $ key ) { $ this -> dataAvailability [ $ key ] = true ; } } | Merges data received from the server with a given selected keys . |
29,880 | private function mergeMagicFields ( & $ data ) { if ( isset ( $ data [ 'objectId' ] ) ) { $ this -> objectId = $ data [ 'objectId' ] ; unset ( $ data [ 'objectId' ] ) ; } if ( isset ( $ data [ 'createdAt' ] ) ) { $ this -> createdAt = new \ DateTime ( $ data [ 'createdAt' ] ) ; unset ( $ data [ 'createdAt' ] ) ; } if ( isset ( $ data [ 'updatedAt' ] ) ) { $ this -> updatedAt = new \ DateTime ( $ data [ 'updatedAt' ] ) ; unset ( $ data [ 'updatedAt' ] ) ; } if ( isset ( $ data [ 'ACL' ] ) ) { $ acl = AVACL :: _createACLFromJSON ( $ data [ 'ACL' ] ) ; $ this -> serverData [ 'ACL' ] = $ acl ; unset ( $ data [ 'ACL' ] ) ; } } | Handle merging of special fields for the object . |
29,881 | protected function rebuildEstimatedData ( ) { $ this -> estimatedData = array ( ) ; foreach ( $ this -> serverData as $ key => $ value ) { $ this -> estimatedData [ $ key ] = $ value ; } $ this -> applyOperations ( $ this -> operationSet , $ this -> estimatedData ) ; } | Start from serverData and process operations to generate the current value set for an object . |
29,882 | private function applyOperations ( $ operations , & $ target ) { foreach ( $ operations as $ key => $ operation ) { $ oldValue = ( isset ( $ target [ $ key ] ) ? $ target [ $ key ] : null ) ; $ newValue = $ operation -> _apply ( $ oldValue , $ this , $ key ) ; if ( empty ( $ newValue ) && ! is_array ( $ newValue ) && $ newValue !== null && ! is_scalar ( $ newValue ) ) { unset ( $ target [ $ key ] ) ; unset ( $ this -> dataAvailability [ $ key ] ) ; } else { $ target [ $ key ] = $ newValue ; $ this -> dataAvailability [ $ key ] = true ; } } } | Apply operations to a target object |
29,883 | public function destroy ( $ useMasterKey = false ) { if ( ! $ this -> objectId ) { return ; } $ sessionToken = null ; if ( AVUser :: getCurrentUser ( ) ) { $ sessionToken = AVUser :: getCurrentUser ( ) -> getSessionToken ( ) ; } AVClient :: _request ( 'DELETE' , '/classes/' . $ this -> className . '/' . $ this -> objectId , $ sessionToken , null , $ useMasterKey ) ; } | Delete the object from Avos . |
29,884 | public static function destroyAll ( array $ objects , $ useMasterKey = false ) { $ errors = [ ] ; $ count = count ( $ objects ) ; if ( $ count ) { $ batchSize = 40 ; $ processed = 0 ; $ currentBatch = [ ] ; $ currentcount = 0 ; while ( $ processed < $ count ) { $ currentcount ++ ; $ currentBatch [ ] = $ objects [ $ processed ++ ] ; if ( $ currentcount == $ batchSize || $ processed == $ count ) { $ results = static :: destroyBatch ( $ currentBatch ) ; $ errors = array_merge ( $ errors , $ results ) ; $ currentBatch = [ ] ; $ currentcount = 0 ; } } if ( count ( $ errors ) ) { throw new AVAggregateException ( "Errors during batch destroy." , $ errors ) ; } } return null ; } | Delete an array of objects . |
29,885 | public function _encode ( ) { $ out = array ( ) ; if ( $ this -> objectId ) { $ out [ 'objectId' ] = $ this -> objectId ; } if ( $ this -> createdAt ) { $ out [ 'createdAt' ] = $ this -> createdAt ; } if ( $ this -> updatedAt ) { $ out [ 'updatedAt' ] = $ this -> updatedAt ; } foreach ( $ this -> serverData as $ key => $ value ) { $ out [ $ key ] = $ value ; } foreach ( $ this -> estimatedData as $ key => $ value ) { if ( is_object ( $ value ) && $ value instanceof \ Avos \ Internal \ Encodable ) { $ out [ $ key ] = $ value -> _encode ( ) ; } else if ( is_array ( $ value ) ) { $ out [ $ key ] = array ( ) ; foreach ( $ value as $ item ) { if ( is_object ( $ item ) && $ item instanceof \ Avos \ Internal \ Encodable ) { $ out [ $ key ] [ ] = $ item -> _encode ( ) ; } else { $ out [ $ key ] [ ] = $ item ; } } } else { $ out [ $ key ] = $ value ; } } return json_encode ( $ out ) ; } | Return a JSON encoded value of the object . |
29,886 | private static function findUnsavedChildren ( $ object , & $ unsavedChildren , & $ unsavedFiles ) { static :: traverse ( true , $ object , function ( $ obj ) use ( & $ unsavedChildren , & $ unsavedFiles ) { if ( $ obj instanceof AVObject ) { if ( $ obj -> _isDirty ( false ) ) { $ unsavedChildren [ ] = $ obj ; } } else if ( $ obj instanceof AVFile ) { if ( ! $ obj -> getURL ( ) ) { $ unsavedFiles [ ] = $ obj ; } } } ) ; } | Find unsaved children inside an object . |
29,887 | private static function traverse ( $ deep , & $ object , $ mapFunction , $ seen = array ( ) ) { if ( $ object instanceof AVObject ) { if ( in_array ( $ object , $ seen , true ) ) { return null ; } $ seen [ ] = $ object ; if ( $ deep ) { self :: traverse ( $ deep , $ object -> estimatedData , $ mapFunction , $ seen ) ; } return $ mapFunction ( $ object ) ; } if ( $ object instanceof AVRelation || $ object instanceof AVFile ) { return $ mapFunction ( $ object ) ; } if ( is_array ( $ object ) ) { foreach ( $ object as $ key => $ value ) { self :: traverse ( $ deep , $ value , $ mapFunction , $ seen ) ; } return $ mapFunction ( $ object ) ; } return $ mapFunction ( $ object ) ; } | Traverse object to find children . |
29,888 | private static function canBeSerializedAsValue ( $ object ) { $ result = true ; self :: traverse ( false , $ object , function ( $ obj ) use ( & $ result ) { if ( $ result === false ) { return ; } if ( $ obj instanceof AVObject ) { if ( ! $ obj -> getObjectId ( ) ) { $ result = false ; return ; } } } ) ; return $ result ; } | Checks the given object and any children to see if the whole object can be serialized for saving . |
29,889 | private function mergeAfterSave ( $ result ) { $ this -> applyOperations ( $ this -> operationSet , $ this -> serverData ) ; $ this -> mergeFromServer ( $ result ) ; $ this -> operationSet = array ( ) ; $ this -> rebuildEstimatedData ( ) ; } | Merge server data after a save completes . |
29,890 | public function getRelation ( $ key ) { $ relation = new AVRelation ( $ this , $ key ) ; if ( isset ( $ this -> estimatedData [ $ key ] ) ) { $ object = $ this -> estimatedData [ $ key ] ; if ( $ object instanceof AVRelation ) { $ relation -> setTargetClass ( $ object -> getTargetClass ( ) ) ; } } return $ relation ; } | Access or create a Relation value for a key . |
29,891 | public static function registerSubclass ( ) { if ( isset ( static :: $ avClassName ) ) { if ( ! in_array ( static :: $ avClassName , self :: $ registeredSubclasses ) ) { self :: $ registeredSubclasses [ static :: $ avClassName ] = get_called_class ( ) ; } } else { throw new \ Exception ( "Cannot register a subclass that does not have a avClassName" ) ; } } | Register a subclass . Should be called before any other Avos functions . Cannot be called on the base class AVObject . |
29,892 | public function resolveWriter ( ResourceUri $ resource ) { if ( ! array_key_exists ( $ resource -> getProtocol ( ) , $ this -> protocolWriterIndexes ) ) { throw new \ RuntimeException ( 'Unsupported protocol: ' . $ resource -> getProtocol ( ) . '( ' . $ resource . ')' ) ; } $ index = $ this -> protocolWriterIndexes [ $ resource -> getProtocol ( ) ] ; return $ this -> writers [ $ index ] ; } | Resolves a writer for the given resource URI . |
29,893 | public function getRoutesPatterns ( ) { $ patterns = [ ] ; $ rows = $ this -> getRoutes ( ) ; if ( $ rows ) foreach ( $ rows as $ route ) { $ patterns [ ] = $ route -> getPattern ( ) ; } return $ patterns ; } | get all route s patterns |
29,894 | public function load ( $ filenames = 'common' , $ basePath = null , $ locale = null ) { $ locale = $ locale ? : $ this -> locale ; $ filenames = ( array ) $ filenames ; if ( ! $ basePath ) { $ basePath = Config :: getCommonPath ( ) ; } elseif ( ! file_exists ( $ basePath ) ) { $ basePath = Config :: getRootPath ( ) . trim ( $ basePath , '/' ) ; } foreach ( $ filenames as $ file ) { if ( ! is_file ( $ file ) ) { $ file = rtrim ( $ basePath , '/' ) . '/lang/' . $ locale . '/' . $ file . '.lang.php' ; } $ content = Ioc :: load ( $ file ) ; if ( $ content && is_array ( $ content ) ) { $ this -> data = array_merge ( $ this -> data , $ content ) ; } } } | load language data default load app basePath |
29,895 | public function translate ( $ key , $ data = null ) { $ rs = isset ( $ this -> data [ $ key ] ) ? $ this -> data [ $ key ] : $ key ; if ( $ rs && ! empty ( $ data ) ) { $ names = array_keys ( $ data ) ; $ names = array_map ( function ( $ pkey ) { return '{' . $ pkey . '}' ; } , $ names ) ; $ rs = str_replace ( $ names , array_values ( $ data ) , $ rs ) ; } return $ rs ; } | Translate and return the string |
29,896 | protected function generateItems ( array $ collection ) { $ this -> _items = [ ] ; $ this -> _children = [ ] ; foreach ( $ collection as $ c ) { foreach ( $ c as $ key => $ value ) { if ( is_array ( $ value ) ) { if ( count ( $ value ) == 1 && isset ( $ value [ 'children' ] ) && is_array ( $ value [ 'children' ] ) ) { if ( ! isset ( $ this -> _children [ $ key ] ) ) { $ this -> _children [ $ key ] = [ ] ; } foreach ( $ value [ 'children' ] as $ kid ) { $ this -> _children [ $ key ] [ ] = $ kid ; } continue ; } if ( ! isset ( $ value [ 'type' ] ) ) { throw new InvalidConfigException ( 'Please specify type for ' . $ key . ' auth item!' ) ; } if ( $ value [ 'type' ] == Item :: TYPE_ROLE ) { $ item = $ this -> _auth -> createRole ( $ key ) ; } elseif ( $ value [ 'type' ] == Item :: TYPE_PERMISSION ) { $ item = $ this -> _auth -> createPermission ( $ key ) ; } else { throw new InvalidConfigException ( 'Wrong type for ' . $ key . ' auth item! Type can be ' . Item :: TYPE_ROLE . ' (role) or ' . Item :: TYPE_PERMISSION . ' (permission).' ) ; } $ item -> description = isset ( $ value [ 'description' ] ) ? $ value [ 'description' ] : null ; $ item -> data = isset ( $ value [ 'data' ] ) ? $ value [ 'data' ] : null ; if ( isset ( $ value [ 'rule' ] ) && $ value [ 'rule' ] instanceof Rule ) { $ rule = $ value [ 'rule' ] ; $ rule -> updatedAt = time ( ) ; $ item -> ruleName = ! empty ( $ rule -> name ) ? $ rule -> name : get_class ( $ rule ) ; $ this -> _items [ $ item -> ruleName ] = $ rule ; } if ( isset ( $ value [ 'children' ] ) && is_array ( $ value [ 'children' ] ) ) { if ( ! isset ( $ this -> _children [ $ key ] ) ) { $ this -> _children [ $ key ] = [ ] ; } foreach ( $ value [ 'children' ] as $ kid ) { $ this -> _children [ $ key ] [ ] = $ kid ; } } } else { $ item = $ this -> _auth -> createPermission ( $ key ) ; $ item -> description = $ value ; } $ this -> _items [ $ key ] = $ item ; } } } | Creating items object using given config data collection |
29,897 | protected function manageItems ( ) { foreach ( $ this -> _items as $ item ) { if ( $ item instanceof Rule ) { $ item_exist = $ this -> _auth -> getRule ( $ item -> name ) ; } elseif ( $ item instanceof Role ) { $ item_exist = $ this -> _auth -> getRole ( $ item -> name ) ; } elseif ( $ item instanceof Permission ) { $ item_exist = $ this -> _auth -> getPermission ( $ item -> name ) ; } else { throw new InvalidParamException ( 'Adding unsupported object type.' ) ; } if ( $ item_exist ) { if ( $ item_exist instanceof __PHP_Incomplete_Class ) { $ need_update = true ; } else if ( $ item_exist instanceof Rule ) { $ item -> updatedAt = $ item_exist -> updatedAt ; $ need_update = serialize ( $ item_exist ) != serialize ( $ item ) ; } else { $ need_update = $ item_exist -> description != $ item -> description || $ item_exist -> ruleName != $ item -> ruleName || $ item_exist -> data != $ item -> data ; } if ( $ need_update ) { Console :: stdout ( "Updating $item->name item data.\n" ) ; $ this -> _auth -> update ( $ item -> name , $ item ) ; } } else { Console :: stdout ( "New item added: $item->name\n" ) ; $ this -> _auth -> add ( $ item ) ; } } $ items = ArrayHelper :: merge ( $ this -> _auth -> getRules ( ) , $ this -> _auth -> getRules ( ) , $ this -> _auth -> getPermissions ( ) ) ; foreach ( $ items as $ existing_item ) { if ( ! isset ( $ this -> _items [ $ existing_item -> name ] ) ) { Console :: stdout ( Console :: ansiFormat ( 'Item removed: ' . $ existing_item -> name . "\n" , [ Console :: FG_RED ] ) ) ; $ this -> _auth -> remove ( $ existing_item ) ; } } } | Adding or deleting items if needed |
29,898 | protected function manageRelations ( ) { foreach ( $ this -> _children as $ p => $ kids ) { $ parent = $ this -> _items [ $ p ] ; foreach ( $ kids as $ k ) { $ kid = $ this -> _items [ $ k ] ; if ( ! $ this -> _auth -> hasChild ( $ parent , $ kid ) ) { Console :: stdout ( $ kid -> name . ' added as a child of ' . $ parent -> name . "\n" ) ; $ this -> _auth -> addChild ( $ parent , $ kid ) ; } } foreach ( $ this -> _auth -> getChildren ( $ p ) as $ current_kid ) { if ( ! in_array ( $ current_kid -> name , $ kids ) ) { Console :: stdout ( Console :: ansiFormat ( 'Relation between ' . $ current_kid -> name . ' and ' . $ parent -> name . " was removed!\n" , [ Console :: FG_RED ] ) ) ; $ this -> _auth -> removeChild ( $ parent , $ current_kid ) ; } } } } | Adding or deleting children if needed |
29,899 | public function update ( array $ collection ) { $ this -> _auth = Yii :: $ app -> authManager ; $ this -> generateItems ( $ collection ) ; $ this -> manageItems ( ) ; $ this -> manageRelations ( ) ; if ( $ this -> _auth instanceof \ yii \ rbac \ DbManager ) { $ this -> _auth -> invalidateCache ( ) ; } } | Updates RBAC configuration using current RBAC manager component . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.