idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
57,800
private function routeAllRulesToRoot ( ) { $ rules = $ this -> rules ; foreach ( $ this -> defaultRules as $ k => $ v ) $ rules [ $ k ] = '/content/nr' ; foreach ( $ rules as $ k => $ v ) $ rules [ $ k ] = '/content/nr' ; $ rules [ '/sitemap.xml' ] = '/site/sitemap' ; $ rules [ '/login' ] = '/site/login' ; $ rules [ '/' ] = '/content/nr' ; $ this -> rules = CMap :: mergeArray ( $ this -> addRSSRules ( ) , $ this -> rules ) ; $ this -> rules = CMap :: mergeArray ( $ this -> addModuleRules ( ) , $ this -> rules ) ; return $ rules ; }
Eraseses all the existing rules and remaps them to the index
57,801
private function generateContentRules ( ) { $ rules = array ( ) ; $ criteria = Content :: model ( ) -> getBaseCriteria ( ) ; $ content = Content :: model ( ) -> findAll ( $ criteria ) ; foreach ( $ content as $ el ) { if ( $ el -> slug == NULL ) continue ; $ pageRule = $ el -> slug . '/<page:\d+>' ; $ rule = $ el -> slug ; $ pageRule = $ el -> slug . '/<page:\d+>' ; $ rule = $ el -> slug ; $ rules [ $ pageRule ] = "content/index/id/{$el->id}/vid/{$el->vid}" ; $ rules [ $ rule ] = "content/index/id/{$el->id}/vid/{$el->vid}" ; } return $ rules ; }
Generates content rules
57,802
private function generateCategoryRules ( ) { $ rules = array ( ) ; $ categories = Categories :: model ( ) -> findAll ( ) ; foreach ( $ categories as $ el ) { if ( $ el -> slug == NULL ) continue ; $ pageRule = $ el -> slug . '/<page:\d+>' ; $ rule = $ el -> slug ; $ pageRule = $ el -> slug . '/<page:\d+>' ; $ rule = $ el -> slug ; $ rules [ $ pageRule ] = "categories/index/id/{$el->id}" ; $ rules [ $ rule ] = "categories/index/id/{$el->id}" ; } return $ rules ; }
Generates category rules
57,803
public function onSuccessActivate ( Event $ event ) { $ user = $ event -> getData ( 'user' ) ; $ this -> _getMailer ( $ user ) -> sendActivationMessage ( ) ; }
On success user activation profile .
57,804
public function onModelAfterSave ( Event $ event ) { $ user = $ event -> getData ( 'user' ) ; if ( $ user instanceof EntityInterface ) { if ( $ user -> isNew ( ) && Filter :: bool ( $ user -> get ( 'notify' ) ) ) { $ this -> _getMailer ( $ user ) -> sendCreateMessage ( ) ; } } }
Global after save user data .
57,805
public function getListnameByListId ( $ listID ) { $ list = $ this -> model -> where ( 'id' , $ listID ) -> first ( ) ; return $ list -> title ; }
Get the list title by ID
57,806
public function setLogger ( string $ id , LoggerInterface $ logger ) : self { $ this -> _loggers [ $ id ] = $ logger ; return $ this ; }
Sets a logger instance .
57,807
public function getLogger ( string $ id ) { if ( ! isset ( $ this -> _loggers [ $ id ] ) ) { throw new \ RuntimeException ( 'Logger with ID "' . $ id . '" is not registered on the logger factory.' ) ; } return $ this -> _loggers [ $ id ] ; }
Returns a logger instance .
57,808
public function createHandler ( string $ id , string $ type , int $ level , array $ config ) : HandlerInterface { if ( ! isset ( $ this -> _handlers [ $ id ] ) ) { $ config = array_replace ( [ 'processorIds' => [ ] ] , $ config ) ; if ( ! is_array ( $ config [ 'processorIds' ] ) ) { throw InvalidConfigException :: create ( 'processorIds' , 'array' ) ; } $ handler = null ; switch ( $ type ) { case self :: HANDLER_TYPE_STREAM : $ config = array_replace ( [ 'bubble' => true , 'filePermission' => null , 'useLocking' => false ] , $ config ) ; if ( ! isset ( $ config [ 'stream' ] ) || ! is_string ( $ config [ 'stream' ] ) ) { throw InvalidConfigException :: create ( 'stream' , 'string' ) ; } $ handler = new StreamHandler ( $ config [ 'stream' ] , $ level , $ config [ 'bubble' ] , $ config [ 'filePermission' ] , $ config [ 'useLocking' ] ) ; $ this -> setHandler ( $ id , $ handler ) ; break ; case self :: HANDLER_TYPE_ERROR_LOG : $ config = array_replace ( [ 'messageType' => ErrorLogHandler :: OPERATING_SYSTEM , 'bubble' => true , 'expandNewLines' => false ] , $ config ) ; $ handler = new ErrorLogHandler ( $ config [ 'messageType' ] , $ level , $ config [ 'bubble' ] , $ config [ 'expandNewLines' ] ) ; $ this -> setHandler ( $ id , $ handler ) ; break ; case self :: HANDLER_TYPE_NULL : $ handler = new NullHandler ( $ level ) ; $ this -> setHandler ( $ id , $ handler ) ; break ; default : throw new \ InvalidArgumentException ( 'Type "' . $ type . '" is not handled yet by this component. You can set manually the handler ' . 'instance using the "setHandler" method.' ) ; } if ( $ config [ 'processorIds' ] ) { foreach ( $ config [ 'processorIds' ] as $ processorId ) { if ( ! isset ( $ this -> _processors [ $ processorId ] ) ) { throw InvalidConfigException :: create ( 'processorIds' , 'array' , 'Additionally, processor ID "' . $ processorId . '" does not exist.' ) ; } $ handler -> pushProcessor ( $ this -> _processors [ $ processorId ] ) ; } } $ this -> _handlers [ $ id ] = $ handler ; } return $ this -> _handlers [ $ id ] ; }
Creates a handler .
57,809
public function setHandler ( string $ handlerId , HandlerInterface $ handler ) : self { $ this -> _handlers [ $ handlerId ] = $ handler ; return $ this ; }
Sets a handler instance .
57,810
public function getHandler ( string $ id ) { if ( ! isset ( $ this -> _handlers [ $ id ] ) ) { throw new \ RuntimeException ( 'Handler with ID "' . $ id . '" is not registered on the logger factory.' ) ; } return $ this -> _handlers [ $ id ] ; }
Returns a handler instance .
57,811
public function setProcessor ( string $ processorId , callable $ processor ) : self { $ this -> _processors [ $ processorId ] = $ processor ; return $ this ; }
Sets a processor instance .
57,812
public function getProcessor ( string $ id ) { if ( ! isset ( $ this -> _processors [ $ id ] ) ) { throw new \ RuntimeException ( 'Processor with ID "' . $ id . '" is not registered on the logger factory.' ) ; } return $ this -> _processors [ $ id ] ; }
Returns a processor instance .
57,813
public function createFormatter ( string $ id , string $ type , array $ config ) : FormatterInterface { if ( ! isset ( $ this -> _formatters [ $ id ] ) ) { switch ( $ type ) { case self :: FORMATTER_TYPE_LINE : $ config = array_replace ( [ 'format' => null , 'dateFormat' => null , 'allowInlineLineBreaks' => false , 'ignoreEmptyContextAndExtra' => false ] , $ config ) ; $ this -> _formatters [ $ id ] = new LineFormatter ( $ config [ 'format' ] , $ config [ 'dateFormat' ] , $ config [ 'allowInlineLineBreaks' ] , $ config [ 'ignoreEmptyContextAndExtra' ] ) ; break ; default : throw InvalidConfigException :: create ( 'type' , 'string' , 'Allowed types: ' . implode ( ', ' , self :: $ availableFormatterTypes ) ) ; } } return $ this -> _formatters [ $ id ] ; }
Creates a Formatter .
57,814
public function setFormatter ( string $ formatterId , FormatterInterface $ formatter ) : self { $ this -> _formatters [ $ formatterId ] = $ formatter ; return $ this ; }
Sets a Formatter instance .
57,815
public function getFormatter ( string $ id ) { if ( ! isset ( $ this -> _formatters [ $ id ] ) ) { throw new \ RuntimeException ( 'Formatter with ID "' . $ id . '" is not registered on the logger factory.' ) ; } return $ this -> _formatters [ $ id ] ; }
Returns a formatter instance .
57,816
public function & createBody ( $ autoadd = true ) { $ body = new PanelBody ( ) ; if ( $ autoadd ) { $ this -> content [ ] = $ body ; } return $ body ; }
Creates a PanelBody object adds it by default to the content stack and returns a reference on it
57,817
protected function parseEnv ( array $ envs , $ path , $ overload ) { foreach ( $ envs as $ key => $ val ) { if ( $ this -> source_marker === $ val ) { $ src = $ this -> expandPath ( $ this -> deReference ( $ key ) , $ path ) ; $ this -> load ( $ src , $ overload ) ; } else { $ this -> setEnv ( $ key , $ this -> deReference ( $ val ) , $ overload ) ; } } return $ this ; }
Parse & set env
57,818
public static function selector ( $ selector , $ child = true ) { $ css = '' ; if ( $ selector -> getType ( ) ) { $ css .= $ selector -> getType ( ) . ' ' ; } if ( ! $ selector -> getTagName ( ) && ! $ selector -> getIdentification ( ) && ! $ selector -> getClasses ( ) && ! $ selector -> getPseudos ( ) ) { $ css .= '*' ; } else { if ( $ selector -> getTagName ( ) ) { $ css .= $ selector -> getTagName ( ) ; } if ( $ selector -> getAttributes ( ) ) { $ css .= implode ( '' , $ selector -> getAttributes ( ) ) ; } if ( $ selector -> getIdentification ( ) ) { $ css .= '#' . $ selector -> getIdentification ( ) ; } if ( $ selector -> getClasses ( ) ) { $ css .= '.' . implode ( '.' , $ selector -> getClasses ( ) ) ; } if ( $ selector -> getPseudos ( ) ) { $ css .= ':' . implode ( ':' , $ selector -> getPseudos ( ) ) ; } if ( $ child && $ selector -> getNext ( ) ) { $ css .= ' ' . self :: selector ( $ selector -> getNext ( ) , true ) ; } } return $ css ; }
Formats a selector
57,819
public function search ( $ params ) { $ query = self :: find ( ) ; $ dataProvider = new \ yii \ data \ ActiveDataProvider ( [ 'query' => $ query , 'pagination' => [ 'pageSize' => 100 , ] , 'sort' => [ 'defaultOrder' => [ 'code' => SORT_DESC ] ] ] ) ; if ( $ this -> load ( $ params ) && $ this -> validate ( ) ) { $ query -> andFilterWhere ( [ 'like' , 'code' , $ this -> code ] ) ; $ query -> andFilterWhere ( [ 'like' , 'name' , $ this -> name ] ) ; $ query -> andFilterWhere ( [ 'is_active' => $ this -> is_active ] ) ; } return $ dataProvider ; }
Search categories list
57,820
public function matchPattern ( string $ pattern ) : Element { $ this -> attributes [ 'pattern' ] = $ pattern ; return $ this -> addTest ( 'pattern' , function ( $ value ) use ( $ pattern ) { return preg_match ( "@^$pattern$@" , trim ( $ value ) ) ; } ) ; }
The field must match the pattern supplied .
57,821
public function maxLength ( int $ length ) : Element { $ this -> attributes [ 'maxlength' ] = ( int ) $ length ; return $ this -> addTest ( 'maxlength' , function ( $ value ) use ( $ length ) { return mb_strlen ( trim ( $ value ) , 'UTF-8' ) <= ( int ) $ length ; } ) ; }
The maximum length of the field .
57,822
public function register ( ) { $ this -> handler = $ this -> make ( Handler :: class ) ; $ this -> handler -> setDebug ( $ this -> app ( ) -> getGeneral ( ) [ 'debug' ] ) -> setLog ( $ this -> app ( ) -> getGeneral ( ) [ 'log' ] ) -> fire ( ) ; $ this -> registerErrorHandler ( ) ; $ this -> registerExceptionHandler ( ) ; }
create a new instance and register handlers
57,823
protected function execute ( InputInterface $ input , OutputInterface $ output ) { $ this -> input = $ input ; $ this -> output = $ output ; $ repository = $ this -> getContainer ( ) -> get ( 'ezpublish.api.repository' ) ; $ contentTypeService = $ repository -> getContentTypeService ( ) ; $ contentLanguageService = $ repository -> getContentLanguageService ( ) ; $ questionHelper = $ this -> getHelper ( 'question' ) ; $ struct = array ( ) ; $ struct [ 'contentTypeGroup' ] = $ this -> getContentTypeGroup ( $ contentTypeService , $ questionHelper ) ; $ struct [ 'contentTypeIdentifier' ] = $ this -> getContentTypeIdentifier ( $ questionHelper ) ; $ struct [ 'contentTypeName' ] = $ this -> getContentTypeName ( $ questionHelper ) ; $ struct [ 'contentTypeMainLanguage' ] = $ this -> getContentTypeMainLanguage ( $ contentLanguageService , $ questionHelper ) ; $ struct [ 'contentTypeNameSchema' ] = $ this -> getContentTypeNameSchema ( $ questionHelper ) ; $ struct [ 'fields' ] = array ( ) ; while ( true ) { $ struct [ 'fields' ] [ ] = $ this -> getContentTypeField ( $ questionHelper , $ struct [ 'contentTypeMainLanguage' ] ) ; $ question = new ConfirmationQuestion ( '<question>Do you want to add new field?</question> ' , false ) ; if ( ! $ questionHelper -> ask ( $ input , $ output , $ question ) ) { $ output -> writeln ( '' ) ; break ; } } $ configResolver = $ this -> getContainer ( ) -> get ( 'ezpublish.config.resolver' ) ; $ adminID = $ configResolver -> getParameter ( 'adminid' , 'smile_ez_tools' ) ; $ contentTypeService = new ContentType ( $ repository ) ; $ contentTypeService -> setAdminID ( $ adminID ) ; try { $ contentTypeService -> add ( $ struct ) ; $ output -> writeln ( "<info>Content type created</info>" ) ; } catch ( UnauthorizedException $ e ) { $ output -> writeln ( "<error>" . $ e -> getMessage ( ) . "</error>" ) ; } catch ( ForbiddenException $ e ) { $ output -> writeln ( "<error>" . $ e -> getMessage ( ) . "</error>" ) ; } }
Execute ContentType generate command
57,824
public static function checkModel ( $ errors , Model $ model ) : array { $ output = [ ] ; if ( ! is_array ( $ errors ) ) { return $ output ; } foreach ( $ errors as $ attribute => $ message ) { $ obj = $ model ; if ( strpos ( $ attribute , '.' ) !== false ) { list ( $ nested , $ attr ) = explode ( '.' , $ attribute ) ; if ( isset ( $ obj -> { $ nested } ) && $ obj -> { $ nested } instanceof Model ) { $ obj = $ obj -> { $ nested } ; $ attribute = $ attr ; } } if ( $ obj -> hasProperty ( $ attribute ) ) { $ output [ Html :: getInputId ( $ obj , $ attribute ) ] = $ message ; } else { $ output [ ] = $ message ; } } return $ output ; }
Check input errors .
57,825
public static function booleanSwitch ( string $ name = '' , array $ values = [ ] , bool $ active = false , array $ attributes = [ ] ) : string { $ defaultAttributes = [ 'method-get' => false ] ; $ userAttributes = \ array_merge ( $ defaultAttributes , $ attributes ) ; $ isEnabled = ! \ array_key_exists ( 'disabled' , $ userAttributes ) ; $ attributes = [ ] ; $ attributes [ 'type' ] = 'hidden' ; $ attributes [ 'name' ] = $ userAttributes [ 'method-get' ] === false ? \ sprintf ( 'MFVARS[%s]' , $ name ) : $ name ; $ attributes [ 'value' ] = $ active === true ? 1 : 0 ; $ attributes [ 'id' ] = isset ( $ userAttributes [ 'id' ] ) ? $ userAttributes [ 'id' ] : $ name ; $ userAttributes = static :: clearAttributes ( $ userAttributes , [ 'method-get' , 'id' , 'disabled' ] ) ; $ switch = [ ] ; $ switch [ ] = Tags :: div ( Tags :: i ( ) , [ 'class' => 'switch cf' ] ) ; $ switch [ ] = Tags :: label ( $ values [ 0 ] , [ 'class' => 'label-0' ] ) ; $ switch [ ] = Tags :: label ( $ values [ 1 ] , [ 'class' => 'label-1' ] ) ; $ switch [ ] = Tags :: input ( \ array_merge ( $ attributes , $ userAttributes ) ) ; $ class = [ 'form-switch' , 'cf' ] ; if ( $ active === true ) { $ class [ ] = 'active' ; } if ( ! $ isEnabled ) { $ class [ ] = 'disabled' ; } return Tags :: div ( $ switch , [ 'class' => \ implode ( ' ' , $ class ) ] ) ; }
Returns boolean switch controll
57,826
public static function Atci13 ( $ rc , $ dc , $ pr , $ pd , $ px , $ rv , $ date1 , $ date2 , & $ ri , & $ di , & $ eo ) { $ astrom = new iauASTROM ( ) ; IAU :: Apci13 ( $ date1 , $ date2 , $ astrom , $ eo ) ; IAU :: Atciq ( $ rc , $ dc , $ pr , $ pd , $ px , $ rv , $ astrom , $ ri , $ di ) ; }
- - - - - - - - - - i a u A t c i 1 3 - - - - - - - - - -
57,827
public function transform ( $ value ) { if ( null === $ value ) { return null ; } if ( ! is_string ( $ value ) ) { throw new UnexpectedTypeException ( $ value , 'string' ) ; } return explode ( $ this -> separator , $ value ) ; }
Transforms a string into an array .
57,828
public function reverseTransform ( $ value ) { if ( null === $ value ) { return false ; } if ( ! is_array ( $ value ) ) { throw new UnexpectedTypeException ( $ value , 'array' ) ; } return implode ( $ this -> separator , $ value ) ; }
Transforms an array into a string .
57,829
private function initMergeRules ( ) { $ rules = $ this -> getDefaultMergeRulechain ( ) ; $ this -> setMergeRules ( $ rules ) ; $ this -> getEventManager ( ) -> trigger ( self :: EVENT_INIT_MERGERULES , $ this , array ( 'rules' => $ rules ) ) ; return $ this ; }
Initialize merge rules
57,830
public function loadFile ( $ file ) { $ xml = file_get_contents ( $ file ) ; if ( ! $ xml ) { return false ; } try { $ this -> setXml ( $ xml ) ; } catch ( \ Exception $ e ) { return false ; } return true ; }
Load xml from file
57,831
public function getNode ( $ xpath = null ) { if ( $ xpath === null ) { return $ this -> getXml ( ) ; } $ result = $ this -> getXml ( ) -> xpath ( $ xpath ) -> current ( ) ; if ( $ result === false ) { $ result = null ; } return $ result ; }
Get a node
57,832
public function getUrl ( ) { if ( ! $ this -> isSortable ( ) ) { return '' ; } $ params = [ 'sort_key' => $ this -> key ] ; if ( $ this -> isSortKey ( ) ) { $ params [ 'sort_order' ] = $ this -> request -> input ( 'sort_order' ) == 'desc' ? 'asc' : 'desc' ; } return '?' . http_build_query ( $ params + $ this -> request -> all ( ) ) ; }
Return the URL parameter string to sort by this column header .
57,833
public function get ( $ key , $ locale = null ) { $ segments = $ this -> parseKey ( $ key ) ; $ group = $ segments [ 0 ] ; $ item = $ segments [ 1 ] ; if ( "" == $ group ) { return "" ; } $ localeArray = $ this -> parseLocale ( $ locale ) ; foreach ( $ localeArray as $ locale ) { $ this -> load ( $ group , $ locale ) ; if ( isset ( $ this -> loaded [ $ group ] [ $ locale ] ) ) { if ( null == $ item ) { return $ this -> loaded [ $ group ] [ $ locale ] ; } elseif ( isset ( $ this -> loaded [ $ group ] [ $ locale ] [ $ item ] ) ) { return $ this -> loaded [ $ group ] [ $ locale ] [ $ item ] ; } } } return "" ; }
get string by key and locale
57,834
public static function byBubbleCallback ( $ list , $ callback = false ) { $ size = count ( $ list ) ; $ sortedList = $ list ; if ( $ size > 0 ) { $ normalizedList = [ ] ; foreach ( $ list as $ item ) { $ normalizedList [ ] = $ item ; } while ( $ size > 0 ) { $ newSize = 0 ; for ( $ i = 1 ; $ i <= $ size - 1 ; $ i ++ ) { if ( $ callback ) { $ swap = call_user_func_array ( $ callback , [ 'a' => $ normalizedList [ $ i - 1 ] , 'b' => $ normalizedList [ $ i ] ] ) ; } else { $ swap = $ normalizedList [ $ i - 1 ] > $ normalizedList [ $ i ] ; } if ( $ swap ) { $ itemA = $ normalizedList [ $ i - 1 ] ; $ itemB = $ normalizedList [ $ i ] ; $ normalizedList [ $ i - 1 ] = $ itemB ; $ normalizedList [ $ i ] = $ itemA ; $ newSize = $ i ; } } $ size = $ newSize ; } $ sortedList = $ normalizedList ; } return $ sortedList ; }
Optimized callback ready bubble sort
57,835
public function resolve ( $ reference ) { if ( ! is_string ( $ reference ) ) { return $ reference ; } $ prefix = substr ( $ reference , 0 , 1 ) ; switch ( 1 ) { case $ prefix === '@' : return $ this -> container -> get ( substr ( $ reference , 1 ) ) ; case $ prefix === '%' : return $ this -> container -> getParameter ( substr ( $ reference , 1 ) ) ; case preg_match ( static :: CONTAINER_REGEXP , $ reference , $ matches ) : return $ this -> container ; case preg_match ( static :: ENVIRONMENT_REGEXP , $ reference , $ matches ) : return getenv ( $ matches [ 1 ] ) ; case preg_match ( static :: CONSTANT_REGEXP , $ reference , $ matches ) : return constant ( $ matches [ 1 ] ) ; default : return $ reference ; } }
Return the resolved value of the given reference
57,836
private function assertStatusCodeEquals ( $ code ) { if ( ! $ this -> getSession ( ) -> getDriver ( ) instanceof Selenium2Driver ) { $ this -> assertSession ( ) -> statusCodeEquals ( $ code ) ; } }
Assert that given code equals the current one .
57,837
private function iAmLoggedInAsRole ( $ role , $ username = 'doyo' ) { $ data = array ( 'username' => $ username , 'password' => 'password' , 'role' => $ role , ) ; $ this -> getSubContext ( 'doyo-data' ) -> thereIsUser ( $ data ) ; $ this -> getSession ( ) -> visit ( $ this -> generateUrl ( 'fos_user_security_login' ) ) ; $ this -> fillField ( 'Nama Pengguna:' , $ username ) ; $ this -> fillField ( 'Password:' , 'password' ) ; $ this -> pressButton ( 'Login' ) ; }
Create user and login with given role .
57,838
public static function getEngine ( ) { if ( ! static :: $ engine ) { $ loader = new \ Twig_Loader_Filesystem ( ) ; $ loader -> setPaths ( __DIR__ . '/../../views' ) ; foreach ( app ( 'extension' ) -> getExtensions ( ) as $ extension ) { $ path = $ extension -> getPath ( ) . '/views' ; if ( file_exists ( $ path ) ) { $ loader -> setPaths ( $ path , $ extension -> getPackage ( ) ) ; } } static :: $ engine = new \ Twig_Environment ( $ loader ) ; static :: $ engine -> addGlobal ( 'assets' , static :: getAssetManager ( ) ) ; static :: $ engine -> addGlobal ( 'config' , Config :: get ( ) ) ; } return static :: $ engine ; }
get the engine instance
57,839
public function latLonToTile ( $ lat , $ lon , $ zoom ) { $ ar = $ this -> LatLonToMeters ( $ lat , $ lon ) ; $ coord = $ this -> MetersToPixels ( $ ar [ 'xm' ] , $ ar [ 'ym' ] , $ zoom ) ; if ( $ coord [ 'yp' ] < $ this -> tileSize ) { $ coord [ 'yp' ] = 0 ; } $ tile_x = intval ( $ coord [ 'xp' ] / $ this -> tileSize ) ; $ tile_y = intval ( $ coord [ 'yp' ] / $ this -> tileSize ) ; $ tile_y = $ this -> GoogleTileYcoord ( $ tile_y , $ zoom ) ; return array ( 'x' => $ tile_x , 'y' => $ tile_y ) ; }
Convert latitude longitude and zoom into tile number
57,840
protected function serialize ( $ data ) { if ( '' === trim ( $ data ) ) { return null ; } if ( null === $ result = json_decode ( $ data , true ) ) { if ( json_last_error ( ) !== JSON_ERROR_NONE ) { throw new ReadException ( json_last_error_msg ( ) , json_last_error ( ) ) ; } } return new ParameterBag ( $ result ) ; }
Serializes a read item into a ParameterBag .
57,841
protected function createReader ( ResourceInterface $ resource ) { try { $ jsonFile = $ resource -> getFile ( ) -> getPathname ( ) ; $ this -> fileObject = new \ SplFileObject ( $ jsonFile ) ; } catch ( EmptyResponseException $ e ) { $ this -> fileObject = new \ ArrayIterator ( ) ; } }
Creates a reader for a resource .
57,842
private function collectUsedNamespace ( array $ tokens , $ stackPointer ) { $ namespace = '' ; $ next = 2 ; do { $ type = $ tokens [ $ stackPointer + $ next ] [ 'type' ] ; if ( $ type === 'T_STRING' || $ type === 'T_NS_SEPARATOR' ) { $ namespace .= $ tokens [ $ stackPointer + $ next ] [ 'content' ] ; } $ next ++ ; } while ( $ tokens [ $ stackPointer ] [ 'line' ] === $ tokens [ $ stackPointer + $ next ] [ 'line' ] ) ; if ( $ namespace === '' ) { $ type = 'Use without namespace found.' ; $ data = [ $ tokens [ $ stackPointer ] [ 'content' ] ] ; $ error = 'Use without qualified namespace found.' ; $ this -> file -> addWarning ( $ error , $ stackPointer , $ type , $ data ) ; } else { $ this -> usePaths [ ] = trim ( $ namespace ) ; } }
Collects all namespaces in use statements .
57,843
private function findFullyQualifiedNameSpaceInDocBlock ( array $ tokens , $ stackPointer , $ commentContext ) { $ compareContext = $ tokens [ $ stackPointer + 2 ] [ 'content' ] ; $ commentContent = substr ( $ tokens [ $ stackPointer + 2 ] [ 'content' ] , 1 ) ; $ commentContent = $ this -> deleteVariableName ( $ commentContent ) ; if ( preg_match ( '/.*\\\\+.*/' , $ compareContext ) !== 0 ) { if ( ! in_array ( $ commentContent , $ this -> usePaths , true ) ) { $ type = 'Production.UseNamespacePath.NoClassImportFound' ; $ data = [ $ tokens [ $ stackPointer + 2 ] [ 'content' ] ] ; $ error = 'Missing use statement for this type.' ; $ this -> file -> addWarning ( $ error , $ stackPointer , $ type , $ data ) ; } $ type = 'Production.UseNamespacePath.FullQualifiedNamespaceFound' ; $ data = [ $ tokens [ $ stackPointer + 2 ] [ 'content' ] ] ; $ error = 'Full qualified namespace in ' . $ commentContext . ' annotation.' ; $ this -> file -> addWarning ( $ error , $ stackPointer , $ type , $ data ) ; } }
Looks for fully qualified namespaces in docblock comments . If there is a match it will be marked as warning .
57,844
protected function _giveGateway ( MongoDB \ Database $ mongoClient ) { $ this -> _q = null ; $ this -> gateway = $ mongoClient ; return $ this ; }
Set Data Gateway
57,845
function setModelPersist ( MongoDB \ BSON \ Persistable $ persistable ) { $ this -> _q = null ; $ this -> typeMap [ 'root' ] = get_class ( $ persistable ) ; $ this -> persist = $ this -> typeMap [ 'root' ] ; return $ this ; }
Set Data Model Object
57,846
protected function _query ( ) { if ( $ this -> _q ) return $ this -> _q ; $ db = $ this -> gateway ; if ( $ this -> persist ) { $ db = $ db -> withOptions ( [ 'typeMap' => $ this -> typeMap , ] ) ; } $ this -> _q = $ db -> selectCollection ( $ this -> collection_name ) ; return $ this -> _q ; }
prepared mongo client with options - select db collection
57,847
private function validateUploadImage ( UploadedFile $ uploadedImage , array $ config ) { $ errors = array ( ) ; foreach ( $ this -> validator -> validateValue ( $ uploadedImage , $ this -> getConstraint ( $ config ) ) as $ error ) { $ errors [ ] = $ error -> getMessage ( ) ; } return $ errors ; }
Validate upload image .
57,848
private function getConstraint ( array $ config ) { $ options = array ( 'maxSize' => '5M' , 'mimeTypes' => $ config [ 'mime_types' ] , 'maxHeight' => $ config [ 'max_height' ] , 'maxWidth' => $ config [ 'max_width' ] , 'minHeight' => $ config [ 'min_height' ] , 'minWidth' => $ config [ 'min_width' ] , ) ; return new Assert \ Image ( $ options ) ; }
Get constraint .
57,849
public function send ( ) { if ( ! $ this -> verify ( ) ) throw new \ MalformesResponseException ( "Malformed response" ) ; else { http_response_code ( $ this -> statusCode ) ; foreach ( $ this -> headers as $ header => $ value ) { header ( $ header . ': ' . $ value ) ; } } echo $ this -> body ; }
sends the HTTP response
57,850
public function signResponse ( $ privateAccountKey ) { $ this -> headers [ SONIC_HEADER__SIGNATURE ] = Signature :: createSignature ( $ this -> getStringForResponseSignature ( ) , $ privateAccountKey ) ; }
signs the response object
57,851
public function require ( ) : IQueueObject { $ this -> checkIfExpired ( ) ; if ( ! $ this -> queue ) { $ this -> cachedTime = time ( ) ; $ this -> queue = $ this -> loader -> require ( ) ; } return $ this -> queue ; }
Exception is thrown if queue does not exist .
57,852
public function getServer ( ) { if ( ! $ this -> has ( 'server' ) ) { $ storages = [ ] ; if ( $ this -> useJwtToken ) { if ( ! array_key_exists ( 'access_token' , $ this -> storageMap ) || ! array_key_exists ( 'public_key' , $ this -> storageMap ) ) { throw new \ yii \ base \ InvalidConfigException ( 'access_token and public_key must be set or set useJwtToken to false' ) ; } \ Yii :: $ container -> clear ( 'public_key' ) ; \ Yii :: $ container -> set ( 'public_key' , $ this -> storageMap [ 'public_key' ] ) ; \ Yii :: $ container -> set ( 'OAuth2\Storage\PublicKeyInterface' , $ this -> storageMap [ 'public_key' ] ) ; \ Yii :: $ container -> clear ( 'access_token' ) ; \ Yii :: $ container -> set ( 'access_token' , $ this -> storageMap [ 'access_token' ] ) ; } foreach ( array_keys ( $ this -> storageMap ) as $ name ) { $ storages [ $ name ] = \ Yii :: $ container -> get ( $ name ) ; } $ grantTypes = [ ] ; foreach ( $ this -> grantTypes as $ name => $ options ) { if ( ! isset ( $ storages [ $ name ] ) || empty ( $ options [ 'class' ] ) ) { throw new \ yii \ base \ InvalidConfigException ( 'Invalid grant types configuration.' ) ; } $ class = $ options [ 'class' ] ; unset ( $ options [ 'class' ] ) ; $ reflection = new \ ReflectionClass ( $ class ) ; $ config = array_merge ( [ 0 => $ storages [ $ name ] ] , [ $ options ] ) ; $ instance = $ reflection -> newInstanceArgs ( $ config ) ; $ grantTypes [ $ name ] = $ instance ; } $ server = \ Yii :: $ container -> get ( Server :: className ( ) , [ $ this , $ storages , array_merge ( [ 'use_jwt_access_tokens' => $ this -> useJwtToken , 'token_param_name' => $ this -> tokenParamName , 'access_lifetime' => $ this -> tokenAccessLifetime , 'require_exact_redirect_uri' => false ] , $ this -> options ) , $ grantTypes ] ) ; $ this -> set ( 'server' , $ server ) ; } return $ this -> get ( 'server' ) ; }
Gets Oauth2 Server
57,853
public function backupDatabase ( ) : TempFile { $ this -> check ( ) ; $ backup = new TempFile ( 'database.sql' , true ) ; $ tables = $ this -> driver -> getTables ( ) ; $ backup -> write ( "SET NAMES utf8;\n" ) ; $ backup -> write ( "SET time_zone = '+00:00';\n" ) ; $ backup -> write ( "SET foreign_key_checks = 0;\n" ) ; $ backup -> write ( "SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';\n\n\n" ) ; foreach ( $ tables as $ table ) { if ( in_array ( $ table , $ this -> excludeTables ) ) { continue ; } $ backup -> write ( "DROP TABLE IF EXISTS `$table`;\n" ) ; $ createTable = $ this -> driver -> getCreateTable ( $ table ) ; $ backup -> write ( "$createTable;\n\n" ) ; $ rows = $ this -> driver -> getRows ( $ table ) ; $ insert = [ ] ; $ columns = null ; $ counter = 0 ; foreach ( $ rows as $ row ) { $ counter ++ ; if ( $ columns === null ) { $ colName = [ ] ; foreach ( $ row as $ key => $ value ) { $ colName [ ] = "`$key`" ; } $ columns = implode ( ', ' , $ colName ) ; } $ cols = [ ] ; foreach ( $ row as $ column ) { if ( is_string ( $ column ) ) { $ column = addslashes ( $ column ) ; $ column = preg_replace ( "/\n/" , "\\n" , $ column ) ; } elseif ( $ column === null ) { $ cols [ ] = 'NULL' ; continue ; } $ cols [ ] = '"' . $ column . '"' ; } $ insert [ ] = implode ( ', ' , $ cols ) ; if ( $ this -> maxRows && $ counter >= $ this -> maxRows ) { $ this -> writeInsert ( $ backup , $ table , $ columns , $ insert ) ; $ counter = 0 ; $ insert = [ ] ; } } $ this -> writeInsert ( $ backup , $ table , $ columns , $ insert ) ; $ backup -> write ( "\n\n" ) ; } return $ backup ; }
Vrati zalohu databaze
57,854
public function compressBackupDatabase ( TempFile $ archive = null ) : TempFile { $ this -> check ( ) ; if ( $ archive === null ) { $ archive = new TempFile ( 'databaze.zip' ) ; } File :: zip ( $ this -> backupDatabase ( ) , ( string ) $ archive ) ; return $ archive ; }
Vrati zabalenou zalohu databaze
57,855
public function addChild ( $ inDataOrNodeInstance ) { $ c = $ inDataOrNodeInstance instanceof Node ? $ inDataOrNodeInstance : new Node ( $ inDataOrNodeInstance ) ; $ c -> setParent ( $ this ) ; $ this -> __children [ ] = $ c ; return $ c ; }
This method is part of the tree builder . Add a child to a given node .
57,856
public function getSiblings ( ) { $ parent = $ this -> getParent ( ) ; if ( is_null ( $ parent ) ) { return [ ] ; } $ children = $ parent -> getChildren ( ) ; $ index = array_search ( $ this , $ children ) ; unset ( $ children [ $ index ] ) ; return $ children ; }
Return the node siblings .
57,857
public function traverse ( callable $ inFunction , array & $ inOutResult ) { $ inFunction ( $ this , $ inOutResult ) ; foreach ( $ this as $ child ) { if ( $ child -> hasChildren ( ) ) { $ child -> traverse ( $ inFunction , $ inOutResult ) ; continue ; } $ inFunction ( $ child , $ inOutResult ) ; } }
Walk through all children of a given node .
57,858
public function copyUntil ( $ string , $ char = false , $ escape = false ) { if ( $ this -> pos >= $ this -> size ) { return '' ; } if ( $ escape ) { $ position = $ this -> pos ; $ found = false ; while ( ! $ found ) { $ position = strpos ( $ this -> content , $ string , $ position ) ; if ( $ position === false ) { $ found = true ; continue ; } if ( $ this -> char ( $ position - 1 ) == '\\' ) { ++ $ position ; continue ; } $ found = true ; } } elseif ( $ char ) { $ position = strcspn ( $ this -> content , $ string , $ this -> pos ) ; $ position += $ this -> pos ; } else { $ position = strpos ( $ this -> content , $ string , $ this -> pos ) ; } if ( $ position === false ) { $ return = substr ( $ this -> content , $ this -> pos , $ this -> size - $ this -> pos ) ; $ this -> pos = $ this -> size ; return $ return ; } if ( $ position == $ this -> pos ) { return '' ; } $ return = substr ( $ this -> content , $ this -> pos , $ position - $ this -> pos ) ; $ this -> pos = $ position ; return $ return ; }
Copy the content until we find the given string .
57,859
public function skipByToken ( $ token , $ copy = false ) { $ string = $ this -> $ token ; return $ this -> skip ( $ string , $ copy ) ; }
Skip a given token of pre - defined characters .
57,860
protected function translateJoin ( JoinClause $ join , Schema & $ schema ) { $ expr = $ join -> getJoinType ( ) . ' ' ; $ condition = $ join -> getCondition ( ) ; if ( $ condition instanceof SQLPredicate ) $ condition = $ condition -> evaluate ( $ this -> driver , $ schema ) ; elseif ( ! is_string ( $ condition ) ) throw new \ InvalidArgumentException ( "Conditions must be specified either by a SQLPredicate instance or a non-empty string" ) ; if ( $ join -> getAlias ( ) ) $ expr .= '@@' . $ join -> getTable ( ) . ' ' . $ join -> getAlias ( ) . ' ON ' . $ condition . ' ' ; else $ expr .= '@@' . $ join -> getTable ( ) . ' ON ' . $ condition . ' ' ; return $ expr ; }
Returns a join expression as a string
57,861
public function build ( AbstractQuery $ query , Schema & $ schema ) { $ from = '' ; $ table = $ query -> getTable ( ) ; $ alias = $ query -> getAlias ( ) ; if ( isset ( $ alias ) ) $ from .= '@@' . $ table . ' ' . $ alias . ' ' ; else $ from .= '@@' . $ table . ' ' ; $ joins = $ query -> getJoins ( ) ; foreach ( $ joins as $ join ) $ from .= $ this -> translateJoin ( $ join , $ schema ) ; return $ from ; }
Returns a FROM clause as a string
57,862
public function check ( $ data ) { foreach ( $ this -> requiredFields as $ field => $ type ) { if ( ! isset ( $ data [ $ field ] ) || empty ( $ data [ $ field ] ) || ! $ this -> isValid ( $ data [ $ field ] , $ type ) ) { throw new ValidatorException ( ValidatorException :: INVALID_INTEGRITY , $ this -> debugDump ( $ field , $ data ) ) ; } } foreach ( $ this -> optionalFields as $ field => $ expectedType ) { if ( ! isset ( $ data [ $ field ] ) ) { continue ; } if ( ! $ this -> isValid ( $ data [ $ field ] , $ expectedType ) ) { throw new ValidatorException ( ValidatorException :: INVALID_INTEGRITY , $ this -> debugDump ( $ field , $ data ) ) ; } } return true ; }
Verifies that the object has the required fields
57,863
public function iconMenu ( \ Zend_Navigation_Container $ container = null ) { if ( null !== $ container ) { $ this -> setContainer ( $ container ) ; } return $ this ; }
View helper execute method
57,864
public function get ( $ item ) { $ key = $ this -> getItemKey ( $ item ) ; if ( null !== $ key ) { if ( isset ( $ this -> items [ $ key ] ) ) { $ item = $ this -> items [ $ key ] ; } else { $ this -> items [ $ key ] = $ item ; } } return $ item ; }
If a item with the same key already exist in the identity map return that item . Only handle items that have non - null keys
57,865
public function getRealPath ( ) { $ path = parent :: getRealPath ( ) ; if ( empty ( $ path ) ) { $ path = $ this -> getRootDir ( ) . $ this -> getFilename ( ) ; } return $ path ; }
Gets the object realpath if found
57,866
public function setRootDir ( $ dir_name ) { $ this -> root_dir = $ dir_name ; $ this -> setWebPath ( $ this -> getWebPath ( ) ) ; return $ this ; }
Sets the object s root directory
57,867
public function getWebPath ( ) { return ( ! empty ( $ this -> web_path ) ? str_replace ( $ this -> getRootDir ( ) , '' , DirectoryHelper :: slashDirname ( $ this -> web_path ) ) : '' ) ; }
Gets the object s web path
57,868
public function rootDirExists ( ) { $ path = $ this -> getRootDir ( ) ; return ! empty ( $ path ) && @ file_exists ( $ path ) && @ is_dir ( $ path ) ; }
Check if the object s root directory exists in the server filesystem
57,869
public function getMimeType ( ) { if ( $ this -> exists ( ) ) { $ finfo = new \ finfo ( FILEINFO_MIME_TYPE | FILEINFO_PRESERVE_ATIME ) ; $ mime = $ finfo -> file ( $ this -> getRealPath ( ) ) ; return $ mime ; } return null ; }
Get the MIME type of the object
57,870
public function getCharset ( ) { if ( $ this -> exists ( ) ) { $ finfo = new \ finfo ( FILEINFO_MIME_ENCODING | FILEINFO_PRESERVE_ATIME ) ; $ mime = $ finfo -> file ( $ this -> getRealPath ( ) ) ; return $ mime ; } return null ; }
Get the MIME charset of the object
57,871
public function getMime ( ) { if ( $ this -> exists ( ) ) { $ finfo = new \ finfo ( FILEINFO_MIME | FILEINFO_PRESERVE_ATIME ) ; $ mime = $ finfo -> file ( $ this -> getRealPath ( ) ) ; return $ mime ; } return null ; }
Get the full MIME information of the object
57,872
protected function setResponseCode ( ) { if ( function_exists ( 'http_status_code' ) ) { http_status_code ( $ this -> statusCode ) ; } else { $ message = $ this -> validStatusCodes [ $ this -> statusCode ] ; $ sapi_type = php_sapi_name ( ) ; if ( substr ( $ sapi_type , 0 , 3 ) == 'cgi' ) { $ this -> headers [ 'Status' ] = new Header ( 'Status' , $ message ) ; } else { $ headerName = "HTTP/1.1 $message" ; $ this -> headers [ 'Status' ] = new Header ( $ headerName ) ; } } }
Set the status code header
57,873
public function redirectTo ( $ url , array $ options = array ( ) ) { $ options = new Hash ( $ options ) ; $ this -> redirectUrl = $ url ; $ this -> setStatusCode ( $ options -> fetch ( 'status' , 302 ) ) ; $ this -> getHeaders ( ) -> offsetSet ( 'Location' , $ url ) ; return $ this ; }
Set the redirection
57,874
protected function writeFile ( $ filePath , $ namespace , $ content , array $ uses = [ ] ) { $ data = '<?php' . ( $ namespace ? "\nnamespace " . $ namespace . ';' : '' ) . "\n\n" ; if ( count ( $ uses ) ) { foreach ( $ uses as $ use ) { $ data .= "use " . $ use . ";\n" ; } $ data .= "\n" ; } $ data .= trim ( preg_replace ( "/\n\n\n+/" , "\n\n" , $ content ) ) ; return file_put_contents ( $ filePath , $ data ) ; }
Write a class file
57,875
protected function cleanType ( ? string $ type ) : ? string { if ( ! $ type || in_array ( strtolower ( $ type ) , [ 'null' , 'mixed' ] ) || strpos ( $ type , '|' ) ) { return null ; } $ lowerType = strtolower ( $ type ) ; if ( in_array ( ltrim ( $ lowerType , '?' ) , [ 'array' , 'int' , 'integer' , 'bool' , 'boolean' , 'float' , 'double' , 'real' , 'string' , 'object' , 'unset' , 'callback' ] ) ) { return $ lowerType ; } return '\\' . ltrim ( $ type , '\\' ) ; }
Data types cleaner
57,876
protected function releaseJobsThatHaveBeenReservedTooLong ( $ queue ) { $ expired = Carbon :: now ( ) -> subSeconds ( $ this -> expire ) -> getTimestamp ( ) ; $ this -> database -> table ( $ this -> table ) -> where ( 'queue' , $ this -> getQueue ( $ queue ) ) -> where ( 'reserved' , 1 ) -> where ( 'reserved_at' , '<=' , $ expired ) -> update ( [ 'reserved' => 0 , 'reserved_at' => null , 'attempts' => new Expression ( 'attempts + 1' ) , ] ) ; }
Release the jobs that have been reserved for too long .
57,877
public function get ( $ name , $ default = null ) { return isset ( $ this -> requestCookies [ $ name ] ) ? $ this -> requestCookies [ $ name ] : $ default ; }
Get request cookie
57,878
public function defaultStack ( ) { $ stack = Configuration :: get ( 'template.defaultStack' ) ; if ( ! is_array ( $ stack ) ) { $ stack = [ ] ; } $ this -> render -> replaceAll ( $ stack ) ; return $ this ; }
Load in the default stack
57,879
public function loadStack ( $ name ) { $ stacks = Configuration :: get ( 'template.stacks' ) ; if ( ! isset ( $ stacks [ $ name ] ) ) { throw new RendererException ( "Stack '" . $ name . "' not found!" ) ; } $ this -> render -> replaceAll ( $ stacks [ $ name ] ) ; return $ this ; }
Load a prepared stack .
57,880
public function body ( $ path , $ data = array ( ) , $ engine = null ) { $ view = new View ( $ path , View :: PART_BODY , $ engine ) ; $ view -> setData ( $ data ) ; if ( $ this -> render -> hasBodyPlaceholderEmpty ( ) ) { $ this -> render -> body ( $ view ) ; } else { $ this -> render -> add ( $ view ) ; } return $ this ; }
Add the body template view . When there is a placeholder still not filled in we will fill it with this body .
57,881
public function template ( $ path , $ data = array ( ) , $ engine = null ) { $ view = new View ( $ path , View :: PART_TEMPLATE , $ engine ) ; $ view -> setData ( $ data ) ; $ this -> render -> add ( $ view ) ; return $ this ; }
Add template part to the stack .
57,882
private function generateGlobalThumb ( $ id ) { $ resource = HCResources :: find ( $ id ) ; if ( ! file_exists ( storage_path ( 'app/' ) . $ resource -> path ) ) return ; if ( strpos ( $ resource -> mime_type , 'image' ) === false || strpos ( $ resource -> mime_type , 'svg' ) !== false ) return ; if ( ! $ resource ) throw new \ Exception ( 'Resource not found: ' . $ id ) ; $ thumbRules = HCThumbs :: where ( 'global' , 1 ) -> get ( ) ; $ dest = implode ( '/' , str_split ( str_pad ( $ resource -> count , 9 , '0' , STR_PAD_LEFT ) , 3 ) ) . '/' ; foreach ( $ thumbRules as $ rule ) { $ destination = generateResourcePublicLocation ( $ dest , $ rule -> width , $ rule -> height , $ rule -> fit ) . $ resource -> extension ; createImage ( storage_path ( 'app/' ) . $ resource -> path , $ destination , $ rule -> width , $ rule -> height , $ rule -> fit ) ; } }
Generating thumbnails for a image record
57,883
public function reorder ( TreeNodeInterface $ node , TreeNodeInterface $ beforeNode ) { if ( $ beforeNode -> getParentNode ( ) -> getId ( ) !== $ node -> getParentNode ( ) -> getId ( ) ) { throw new InvalidNodeMoveException ( 'Node and targetNode need to have the same parent.' ) ; } if ( $ node -> getParentNode ( ) -> getSortMode ( ) !== 'free' ) { return ; } $ sort = $ beforeNode -> getSort ( ) + 1 ; $ event = new ReorderNodeEvent ( $ node , $ sort ) ; if ( $ this -> dispatcher -> dispatch ( TreeEvents :: BEFORE_REORDER_NODE , $ event ) -> isPropagationStopped ( ) ) { return ; } $ updatesNodes = [ ] ; $ currentSort = $ sort + 1 ; foreach ( $ this -> getChildren ( $ node -> getParentNode ( ) ) as $ childNode ) { if ( $ childNode -> getSort ( ) <= $ sort ) { $ childNode -> setSort ( $ currentSort ++ ) ; $ updatesNodes [ ] = $ childNode ; } } $ node -> setSort ( $ sort ) ; $ updateNodes [ ] = $ node ; $ this -> updateNodes ( $ updateNodes ) ; $ event = new NodeEvent ( $ node ) ; $ this -> dispatcher -> dispatch ( TreeEvents :: REORDER_NODE , $ event ) ; return ; }
Reorders node after beforeNode .
57,884
function giveCollection ( MongoDB \ Collection $ collection ) { if ( $ this -> collection ) throw new exImmutable ; $ this -> collection = $ collection ; return $ this ; }
Set Mongo Collection Instance
57,885
public function ifStates ( $ translate = false ) { $ states = $ this -> getSNMP ( ) -> walk1d ( self :: OID_VLAN_IF_STATUS ) ; if ( ! $ translate ) return $ states ; return $ this -> getSNMP ( ) -> translate ( $ states , self :: $ IF_VLAN_STATES ) ; }
Get the device s VLAN states
57,886
public function ifLoopbackModeFlags ( $ translate = false ) { $ states = $ this -> getSNMP ( ) -> walk1d ( self :: OID_VLAN_IF_LOOPBACK_MODE_FLAG ) ; if ( ! $ translate ) return $ states ; return $ this -> getSNMP ( ) -> translate ( $ states , self :: $ IF_VLAN_LOOPBACK_MODE_FLAGS ) ; }
Get the device s VLAN loopback mode flags
57,887
public function idsToNames ( ) { $ names = $ this -> ifDescriptions ( ) ; $ ids = $ this -> ifVlanIds ( ) ; $ ids = array_intersect_key ( $ ids , $ names ) ; $ names = array_intersect_key ( $ names , $ ids ) ; return ( array_combine ( $ ids , $ names ) ) ; }
Get the device s VLAN IDs mapped to names
57,888
public function actionTagList ( $ search = NULL ) { $ query = new Query ; if ( ! is_Null ( $ search ) ) { $ mainQuery = $ query -> select ( 'name AS id, name AS text' ) -> distinct ( ) -> from ( '{{%tag}}' ) -> where ( 'UPPER(name) LIKE "%' . strtoupper ( $ search ) . '%"' ) -> limit ( 10 ) ; $ command = $ mainQuery -> createCommand ( ) ; $ rows = $ command -> queryAll ( ) ; $ clean [ 'results' ] = array_values ( $ rows ) ; } $ clean [ 'results' ] [ ] = [ 'id' => $ search , 'text' => $ search ] ; header ( 'Content-type: application/json' ) ; echo Json :: encode ( $ clean ) ; exit ( ) ; }
Will return a JSON array of the matching tags that may have a content passed over as search
57,889
public function getReplacements ( ) : array { $ replacements = [ 'blank' => '' , 'class' => $ this -> getClassName ( ) , 'message' => $ this -> getValue ( ) , ] ; $ traceReplacements = $ this -> getTraceReplacements ( ) ; return array_merge ( $ replacements , $ traceReplacements ) ; }
Devuelve los replacements
57,890
public function createOptions ( array $ options ) { foreach ( $ options as $ categoryKey => $ category ) { foreach ( $ options [ $ categoryKey ] as $ key => $ option ) { foreach ( Language :: all ( ) -> toArray ( ) as $ lang ) { $ options [ $ categoryKey ] [ $ key ] [ $ lang [ 'code' ] ] = config ( 'gzero.' . $ categoryKey . '.' . $ key ) ; } } } foreach ( $ options as $ category => $ option ) { foreach ( $ option as $ key => $ value ) { OptionCategory :: find ( $ category ) -> options ( ) -> create ( [ 'key' => $ key , 'value' => $ value ] ) ; } } }
Create options based on given array .
57,891
public function listAction ( Request $ request ) { $ type = $ request -> get ( 'type' , Elementtype :: TYPE_FULL ) ; $ elementtypeService = $ this -> get ( 'phlexible_elementtype.elementtype_service' ) ; $ elementtypes = [ ] ; foreach ( $ elementtypeService -> findAllElementtypes ( ) as $ elementtype ) { if ( $ type !== $ elementtype -> getType ( ) ) { continue ; } if ( $ elementtype -> getDeleted ( ) ) { continue ; } $ elementtypes [ $ elementtype -> getTitle ( ) . $ elementtype -> getId ( ) ] = [ 'id' => $ elementtype -> getId ( ) , 'title' => $ elementtype -> getTitle ( ) , 'icon' => $ elementtype -> getIcon ( ) , 'version' => $ elementtype -> getRevision ( ) , 'type' => $ elementtype -> getType ( ) , ] ; } ksort ( $ elementtypes ) ; $ elementtypes = array_values ( $ elementtypes ) ; $ checker = $ this -> get ( 'phlexible_element.checker' ) ; $ changes = $ checker -> check ( ) ; $ hasChanges = false ; foreach ( $ changes as $ change ) { if ( $ change -> getNeedImport ( ) ) { $ hasChanges = true ; break ; } } return new JsonResponse ( [ 'elementtypes' => $ elementtypes , 'total' => count ( $ elementtypes ) , 'changes' => $ hasChanges , ] ) ; }
List elementtypes .
57,892
public function createAction ( Request $ request ) { $ title = $ request -> get ( 'title' ) ; $ type = $ request -> get ( 'type' ) ; $ uniqueId = $ request -> get ( 'unique_id' ) ; if ( ! $ uniqueId ) { $ uniqueId = preg_replace ( '/[^a-z0-9_]/' , '_' , strtolower ( $ title ) ) ; } $ elementtypeService = $ this -> get ( 'phlexible_elementtype.elementtype_service' ) ; $ elementtypeService -> createElementtype ( $ type , $ uniqueId , $ title , null , null , [ ] , $ this -> getUser ( ) -> getId ( ) ) ; return new ResultResponse ( true , 'Element Type created.' ) ; }
Create an elementtype .
57,893
public function deleteAction ( Request $ request ) { $ id = $ request -> get ( 'id' ) ; $ elementtypeService = $ this -> get ( 'phlexible_elementtype.elementtype_service' ) ; $ elementtype = $ elementtypeService -> findElementtype ( $ id ) ; $ elementtypeService -> deleteElementtype ( $ elementtype ) ; return new ResultResponse ( true , "Element type $id soft deleted." ) ; }
Delete an elementtype .
57,894
public function duplicateAction ( Request $ request ) { $ id = $ request -> get ( 'id' ) ; $ elementtypeService = $ this -> get ( 'phlexible_elementtype.elementtype_service' ) ; $ sourceElementtype = $ elementtypeService -> findElementtype ( $ id ) ; $ elementtype = $ elementtypeService -> duplicateElementtype ( $ sourceElementtype , $ this -> getUser ( ) -> getUsername ( ) ) ; return new ResultResponse ( true , 'Element type duplicated.' ) ; }
Duplicate elementtype .
57,895
public function edit ( $ entityId ) { $ entity = $ this -> show ( $ entityId ) ; $ form = $ this -> getForm ( ) ; $ this -> set ( compact ( 'form' ) ) ; if ( ! $ entity instanceof EntityInterface ) { return ; } $ form -> setData ( $ entity -> asArray ( ) ) ; if ( ! $ form -> wasSubmitted ( ) ) { return ; } try { $ this -> getUpdateService ( ) -> setEntity ( $ entity ) -> setForm ( $ form ) -> update ( ) ; ; } catch ( InvalidFormDataException $ caught ) { Log :: logger ( ) -> addNotice ( $ caught -> getMessage ( ) , $ form -> getData ( ) ) ; $ this -> addErrorMessage ( $ this -> getInvalidFormDataMessage ( ) ) ; return ; } catch ( \ Exception $ caught ) { Log :: logger ( ) -> addCritical ( $ caught -> getMessage ( ) , $ form -> getData ( ) ) ; $ this -> addErrorMessage ( $ this -> getGeneralErrorMessage ( $ caught ) ) ; return ; } $ this -> addSuccessMessage ( $ this -> getEditSuccessMessage ( $ this -> getUpdateService ( ) -> getEntity ( ) ) ) ; $ this -> redirectFromEdit ( $ entity ) ; }
Handle the request to edit an entity
57,896
protected function getEditSuccessMessage ( EntityInterface $ entity ) { $ singleName = $ this -> getEntityNameSingular ( ) ; $ message = "The {$singleName} '%s' was successfully updated." ; return sprintf ( $ this -> translate ( $ message ) , $ entity ) ; }
Get the update successful entity message
57,897
public function buildPostData ( $ data ) { $ binary_data = false ; if ( is_array ( $ data ) ) { if ( isset ( $ this -> headers [ 'Content-Type' ] ) && preg_match ( $ this -> jsonPattern , $ this -> headers [ 'Content-Type' ] ) ) { $ json_str = json_encode ( $ data ) ; if ( ! ( $ json_str === false ) ) { $ data = $ json_str ; } } else { if ( self :: is_array_multidim ( $ data ) ) { $ data = self :: array_flatten_multidim ( $ data ) ; } foreach ( $ data as $ key => $ value ) { if ( is_string ( $ value ) && strpos ( $ value , '@' ) === 0 && is_file ( substr ( $ value , 1 ) ) ) { $ binary_data = true ; if ( class_exists ( 'CURLFile' ) ) { $ data [ $ key ] = new \ CURLFile ( substr ( $ value , 1 ) ) ; } } elseif ( $ value instanceof \ CURLFile ) { $ binary_data = true ; } } } } if ( ! $ binary_data && ( is_array ( $ data ) || is_object ( $ data ) ) ) { $ data = http_build_query ( $ data , '' , '&' ) ; } return $ data ; }
Build Post Data
57,898
public function setDefaultUserAgent ( ) { $ user_agent = 'PHP-Curl-Class/' . self :: VERSION . ' (+https://github.com/php-curl-class/php-curl-class)' ; $ user_agent .= ' PHP/' . PHP_VERSION ; $ curl_version = curl_version ( ) ; $ user_agent .= ' curl/' . $ curl_version [ 'version' ] ; $ this -> setUserAgent ( $ user_agent ) ; }
Set Default User Agent
57,899
private function parseRequestHeaders ( $ raw_headers ) { $ request_headers = new CaseInsensitiveArray ( ) ; list ( $ first_line , $ headers ) = $ this -> parseHeaders ( $ raw_headers ) ; $ request_headers [ 'Request-Line' ] = $ first_line ; foreach ( $ headers as $ key => $ value ) { $ request_headers [ $ key ] = $ value ; } return $ request_headers ; }
Parse Request Headers