idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
19,400
function is_running ( ) { if ( isset ( $ this -> stopped ) ) { return false ; } if ( ! isset ( $ this -> started ) ) { trigger_error ( "Timer has been stopped some how (" . gettype ( $ this -> started ) . ")'$this->started'" , E_USER_WARNING ) ; return false ; } return true ; }
Test whether timer is running
19,401
function milliseconds ( $ dp = null ) { if ( $ this -> is_running ( ) ) { $ now = microtime ( false ) ; } else { $ now = $ this -> stopped ; } $ started = self :: parse_microtime ( $ this -> started ) ; $ stopped = self :: parse_microtime ( $ now ) ; $ ms = $ stopped - $ started ; if ( ! is_null ( $ dp ) ) { $ mult = pow ( 10 , $ dp ) ; $ ms = round ( $ mult * $ ms ) / $ mult ; } return $ ms ; }
Get milliseconds since timer started .
19,402
function seconds ( $ dp = 2 ) { $ secs = $ this -> milliseconds ( ) / 1000 ; if ( ! is_null ( $ dp ) ) { $ mult = pow ( 10 , $ dp ) ; $ secs = round ( $ mult * $ secs ) / $ mult ; } return $ secs ; }
Get seconds since timer started .
19,403
static function parse_microtime ( $ microtime ) { list ( $ usec , $ sec ) = explode ( ' ' , $ microtime ) ; $ ms1 = ( float ) $ usec * 1000 ; $ ms2 = ( float ) $ sec * 1000 ; return $ ms1 + $ ms2 ; }
Parses string microtime into milliseconds .
19,404
public function getMetadataFor ( $ entityName , array $ parentName = array ( ) ) { return $ this -> hydrateDataObject ( $ this -> entityManager -> getMetadataFactory ( ) -> getMetadataFor ( $ entityName ) , $ parentName ) ; }
Getting metadata for a particulary entity
19,405
static function init ( ) { switch ( PHP_SAPI ) { case 'cli' : break ; case 'cgi' : if ( ! defined ( 'STDERR' ) ) { define ( 'STDERR' , fopen ( 'php://stderr' , 'w' ) ) ; } if ( ! defined ( 'STDOUT' ) ) { define ( 'STDOUT' , fopen ( 'php://stdout' , 'w' ) ) ; } break ; default : echo "Command line only\n" ; exit ( 1 ) ; } PLUG :: set_error_logger ( array ( __CLASS__ , 'format_logline' ) ) ; global $ argv , $ argc ; for ( $ i = 1 ; $ i < $ argc ; $ i ++ ) { $ arg = $ argv [ $ i ] ; $ pair = explode ( '=' , $ arg , 2 ) ; if ( isset ( $ pair [ 1 ] ) ) { $ name = trim ( $ pair [ 0 ] ) ; if ( strpos ( $ name , '--' ) === 0 ) { $ name = trim ( $ name , '-' ) ; } $ name and self :: $ args [ $ name ] = trim ( $ pair [ 1 ] ) ; } else if ( strpos ( $ arg , '--' ) === 0 ) { $ name = trim ( $ arg , "-\n\r\t " ) ; $ name and self :: $ args [ $ name ] = true ; } else if ( $ arg && $ arg { 0 } === '-' ) { $ flags = preg_split ( '//' , trim ( $ arg , "-\n\r\t " ) , - 1 , PREG_SPLIT_NO_EMPTY ) ; foreach ( $ flags as $ flag ) { self :: $ args [ $ flag ] = true ; } continue ; } else if ( isset ( $ flag ) ) { self :: $ args [ $ flag ] = trim ( $ arg ) ; } unset ( $ flag ) ; } }
Initialize PLUG CLI environment
19,406
final static function arg ( $ a , $ default = null ) { if ( is_int ( $ a ) ) { global $ argv ; return isset ( $ argv [ $ a ] ) ? $ argv [ $ a ] : $ default ; } else { return isset ( self :: $ args [ $ a ] ) ? self :: $ args [ $ a ] : $ default ; } }
Get command line argument
19,407
final static function stderr ( $ s ) { if ( func_num_args ( ) > 1 ) { $ args = func_get_args ( ) ; $ s = call_user_func_array ( 'sprintf' , $ args ) ; } fwrite ( STDERR , $ s ) ; }
Print to stderr
19,408
static function format_logline ( PLUGError $ Err ) { if ( PLUG :: is_compiled ( ) ) { return sprintf ( '%s: %s: %s' , basename ( self :: arg ( 0 ) ) , $ Err -> getTypeString ( ) , $ Err -> getMessage ( ) ) ; } else { return sprintf ( '%s: %s: %s in %s#%u' , basename ( self :: arg ( 0 ) ) , $ Err -> getTypeString ( ) , $ Err -> getMessage ( ) , basename ( $ Err -> getFile ( ) ) , $ Err -> getLine ( ) ) ; } }
Standard error logger printing to stderr with program name
19,409
public function getLeagueGlideServer ( ) { if ( null === $ this -> server ) { $ config = $ this -> config + [ 'response' => new LaravelResponseFactory ( $ this -> app [ 'request' ] ) ] ; $ this -> server = ServerFactory :: create ( $ config ) ; } return $ this -> server ; }
Return the league glide server instance for this glide server .
19,410
public function url ( $ path , array $ params = [ ] ) { $ urlBuilder = UrlBuilderFactory :: create ( $ this -> config [ 'base_url' ] , $ this -> config [ 'sign_key' ] ) ; return $ urlBuilder -> getUrl ( $ path , $ params ) ; }
Return image url .
19,411
public function rise ( array $ params , $ line , $ filename ) { $ this -> message = "The length of \"" . $ params [ 0 ] . "\" is invalid! Must be " . $ params [ 1 ] . " then " . $ params [ 2 ] . ". File: " . $ filename . " Line: " . $ line ; return $ this ; }
Rise error message for Length Exceptions
19,412
private function buildLabels ( $ labels ) { $ collection = [ ] ; foreach ( $ labels as $ label ) { $ collection [ ] = Label :: createFromData ( $ label ) ; } return $ collection ; }
Set the Label collection from an array .
19,413
public static function getInstance ( ) { $ fileManager = new FileManager ( ) ; $ serviceManager = ZendFramework2Environnement :: getDependence ( $ fileManager ) ; $ entityManager = $ serviceManager -> get ( 'doctrine.entitymanager.orm_default' ) ; if ( ( $ entityManager instanceof EntityManager ) === false ) { throw new \ Exception ( sprintf ( 'Service manager return instanceof "%s" instead of "%s"' , is_object ( $ entityManager ) === true ? get_class ( $ entityManager ) : gettype ( $ entityManager ) , 'Doctrine\ORM\EntityManager' ) ) ; } return new Doctrine2MetaDataDAO ( $ entityManager ) ; }
Create Doctrine2MetaDataDAO instance
19,414
public function getUploadResult ( $ token ) { $ jwt = new Jwt ( ) ; $ claims = $ jwt -> decode ( $ token , false ) ; if ( ! isset ( $ claims [ 'scope' ] ) ) { throw new AuthenticationException ( 'scope is not exists' ) ; } if ( $ claims [ 'scope' ] !== 'bos.object.create.response' ) { throw new AuthenticationException ( [ '`:scope` scope is not valid' , 'scope' => $ claims [ 'scope' ] ] ) ; } if ( ! isset ( $ claims [ 'bucket' ] ) ) { throw new AuthenticationException ( 'bucket is not exists' ) ; } $ bucket = $ claims [ 'bucket' ] ; $ this -> logger -> info ( $ token , 'bosClient.getUploadResult' ) ; $ jwt -> verify ( $ token , is_string ( $ this -> _access_key ) ? $ this -> _access_key : $ this -> _access_key [ $ bucket ] ) ; return array_except ( $ claims , [ 'scope' , 'iat' , 'exp' ] ) ; }
verify token of create object response
19,415
public function passCsv ( ) { $ csv = fopen ( 'php://output' , 'w' ) ; fputcsv ( $ csv , $ this -> _getHeader ( ) ) ; foreach ( $ this -> _getData ( ) as $ data ) { fputcsv ( $ csv , $ data ) ; } fclose ( $ csv ) ; }
Parsuje dane do postaci CSV
19,416
protected function _getHeader ( ) { $ header = [ ] ; foreach ( $ this -> _grid -> getColumns ( ) as $ column ) { if ( $ column instanceof Column \ IndexColumn || $ column instanceof Column \ OperationColumn ) { continue ; } if ( $ column instanceof Column \ CustomColumn && ! $ column -> getExporting ( ) ) { continue ; } $ header [ ] = $ column -> getLabel ( ) ; } return $ header ; }
Wybiera etykiety kolumn CSV
19,417
public function accept ( ) { $ serviceId = $ this -> current ( ) ; if ( in_array ( $ serviceId , $ this -> getIdsOfServicesThatAreDefinedInApplication ( ) ) ) { return true ; } if ( $ this -> startsWithPrefix ( $ serviceId , $ this -> getPrefixesOfApplicationServices ( ) ) ) { return true ; } return false ; }
Checks if the current service ID is defined directly in the application .
19,418
protected function getIdsOfServicesThatAreDefinedInApplication ( ) { if ( $ this -> serviceIdWhitelist === null ) { $ builder = $ this -> createContainerBuilder ( ) ; $ this -> applyToExtensions ( function ( ExtensionInterface $ extension ) use ( $ builder ) { $ extension -> load ( $ builder -> getExtensionConfig ( $ extension -> getAlias ( ) ) , $ builder ) ; } ) ; $ this -> serviceIdWhitelist = $ builder -> getServiceIds ( ) ; } return $ this -> serviceIdWhitelist ; }
Returns all IDs of services that are clearly defined in the application bundles .
19,419
protected function getPrefixesOfApplicationServices ( ) { if ( $ this -> allowedServicePrefixes === null ) { $ this -> allowedServicePrefixes = $ this -> applyToExtensions ( function ( ExtensionInterface $ extension ) { return $ extension -> getAlias ( ) . '.' ; } ) ; } return $ this -> allowedServicePrefixes ; }
Returns the prefixes that should be used by services that are defined in application bundles .
19,420
protected function applyToExtensions ( $ callback ) { $ results = array ( ) ; foreach ( new ApplicationBundleIterator ( $ this -> kernel ) as $ bundle ) { $ extension = $ bundle -> getContainerExtension ( ) ; if ( $ extension !== null ) { $ results [ ] = call_user_func ( $ callback , $ extension ) ; } } return $ results ; }
Applies the given callback to all bundle extensions that are defined in the application and returns an array with the results of each call .
19,421
protected function startsWithPrefix ( $ serviceId , $ allowedPrefixes ) { foreach ( $ allowedPrefixes as $ prefix ) { if ( strpos ( $ serviceId , $ prefix ) === 0 ) { return true ; } } return false ; }
Checks if the given service ID starts with any of the provided prefixes .
19,422
protected function createContainerBuilder ( ) { $ builder = new ContainerBuilder ( ) ; $ this -> kernel -> boot ( ) ; foreach ( $ this -> kernel -> getBundles ( ) as $ bundle ) { $ extension = $ bundle -> getContainerExtension ( ) ; if ( $ extension !== null ) { $ builder -> registerExtension ( $ extension ) ; } } $ locator = $ this -> kernel -> getContainer ( ) -> get ( 'file_locator' ) ; $ loaders = array ( new XmlFileLoader ( $ builder , $ locator ) , new YamlFileLoader ( $ builder , $ locator ) , new IniFileLoader ( $ builder , $ locator ) , new PhpFileLoader ( $ builder , $ locator ) , ( class_exists ( DirectoryLoader :: class ) ? new DirectoryLoader ( $ builder , $ locator ) : null ) , new ClosureLoader ( $ builder ) , ) ; $ loaders = array_filter ( $ loaders ) ; $ resolver = new LoaderResolver ( $ loaders ) ; $ loader = new DelegatingLoader ( $ resolver ) ; $ this -> kernel -> registerContainerConfiguration ( $ loader ) ; return $ builder ; }
Creates a pre - configured container builder .
19,423
public function getCommits ( ) { if ( '' === ini_get ( 'user_agent' ) ) { throw new UserAgentNotFoundException ( ) ; } if ( ! ini_get ( 'allow_url_fopen' ) ) { throw new AllowUrlFileOpenException ( ) ; } $ jsonResponse = $ this -> getFileContent ( $ this -> getCommitsUrl ( ) , ini_get ( 'user_agent' ) ) ; $ response = json_decode ( $ jsonResponse , true ) ; foreach ( $ response as $ commitArray ) { $ commit = Commit :: createFromData ( $ commitArray [ 'commit' ] ) -> setSha ( $ commitArray [ 'sha' ] ) ; $ commits [ ] = $ commit ; } return $ commits ; }
Get the commits .
19,424
private function getFileContent ( $ url , $ userAgent ) { $ opts = [ 'http' => [ 'method' => 'GET' , 'header' => [ 'User-Agent: ' . $ userAgent ] ] ] ; $ context = stream_context_create ( $ opts ) ; return file_get_contents ( $ url , false , $ context ) ; }
A better file_get_contents
19,425
static function downloadRemoteFile ( $ url , $ destinationFilename ) { if ( ! ini_get ( 'allow_url_fopen' ) ) { throw new \ Exception ( 'allow_url_fopen is disable' , 501 ) ; } $ message = "File was not loaded" ; if ( function_exists ( 'curl_init' ) ) { try { $ raw = file_get_contents ( $ url ) ; } catch ( \ Exception $ e ) { throw new \ Exception ( $ message , Consts :: ERROR_CODE_BAD_REQUEST ) ; } } else { $ ch = curl_init ( $ url ) ; curl_setopt ( $ ch , CURLOPT_HEADER , 0 ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ ch , CURLOPT_FOLLOWLOCATION , 1 ) ; curl_setopt ( $ ch , CURLOPT_BINARYTRANSFER , 1 ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , false ) ; curl_setopt ( $ ch , CURLOPT_CONNECTTIMEOUT , 30 ) ; $ response = parse_url ( $ url ) ; curl_setopt ( $ ch , CURLOPT_REFERER , $ response [ 'scheme' ] . '://' . $ response [ 'host' ] ) ; curl_setopt ( $ ch , CURLOPT_USERAGENT , 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) ' . 'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.99 YaBrowser/19.1.1.907 Yowser/2.5 Safari/537.36' ) ; $ raw = curl_exec ( $ ch ) ; if ( ! $ raw ) { throw new \ Exception ( $ message , Consts :: ERROR_CODE_BAD_REQUEST ) ; } curl_close ( $ ch ) ; } if ( $ raw ) { file_put_contents ( $ destinationFilename , $ raw ) ; } else { throw new \ Exception ( $ message , Consts :: ERROR_CODE_BAD_REQUEST ) ; } }
Download remote file on server
19,426
function lookup ( $ state , $ la ) { if ( ! isset ( $ this -> table [ $ state ] [ $ la ] ) ) { return null ; } else { return $ this -> table [ $ state ] [ $ la ] ; } }
Lookup action by state and lookahead symbol
19,427
private function _applyFilters ( \ Mmi \ Orm \ Query $ query ) { foreach ( $ this -> getFilters ( ) as $ filter ) { if ( ! ( $ filter instanceof GridStateFilter ) ) { throw new GridException ( 'Invalid state filter object' ) ; } if ( $ filter -> getMethod ( ) == 'equals' ) { $ query -> andField ( $ filter -> getField ( ) , $ filter -> getTableName ( ) ) -> equals ( $ filter -> getValue ( ) ) ; continue ; } if ( $ filter -> getMethod ( ) == 'like' ) { $ query -> andField ( $ filter -> getField ( ) , $ filter -> getTableName ( ) ) -> like ( $ filter -> getValue ( ) . '%' ) ; continue ; } if ( $ filter -> getMethod ( ) == 'null' ) { if ( $ filter -> getValue ( ) ) { $ query -> andField ( $ filter -> getField ( ) , $ filter -> getTableName ( ) ) -> notEquals ( null ) ; continue ; } $ query -> andField ( $ filter -> getField ( ) , $ filter -> getTableName ( ) ) -> equals ( null ) ; continue ; } if ( $ filter -> getMethod ( ) == 'between' ) { $ range = explode ( ';' , $ filter -> getValue ( ) ) ; if ( ! empty ( $ range [ 0 ] ) ) { $ query -> andField ( $ filter -> getField ( ) , $ filter -> getTableName ( ) ) -> greaterOrEquals ( $ range [ 0 ] ) ; } if ( isset ( $ range [ 1 ] ) && ! empty ( $ range [ 1 ] ) ) { $ query -> andField ( $ filter -> getField ( ) , $ filter -> getTableName ( ) ) -> lessOrEquals ( $ range [ 1 ] ) ; } continue ; } $ query -> andField ( $ filter -> getField ( ) , $ filter -> getTableName ( ) ) -> like ( '%' . $ filter -> getValue ( ) . '%' ) ; } return $ this ; }
Stosuje filtry na zapytaniu
19,428
private function _applyOrder ( \ Mmi \ Orm \ Query $ query ) { $ orders = $ this -> getOrder ( ) ; if ( ! empty ( $ orders ) ) { $ query -> resetOrder ( ) ; } foreach ( $ orders as $ order ) { if ( ! ( $ order instanceof GridStateOrder ) ) { throw new GridException ( 'Invalid state order object' ) ; } $ query -> { $ order -> getMethod ( ) } ( $ order -> getField ( ) , $ order -> getTableName ( ) ) ; } return $ this ; }
Stosuje sortowania na zapytaniu
19,429
public function isGoodFile ( Config $ source ) { $ info = pathinfo ( $ this -> path ) ; if ( ! isset ( $ info [ 'extension' ] ) or ( ! in_array ( strtolower ( $ info [ 'extension' ] ) , $ source -> extensions ) ) ) { return false ; } if ( in_array ( strtolower ( $ info [ 'extension' ] ) , $ source -> imageExtensions ) and ! $ this -> isImage ( ) ) { return false ; } return true ; }
Check file extension
19,430
public function isImage ( ) { try { if ( ! function_exists ( 'exif_imagetype' ) && ! function_exists ( 'Jodit\exif_imagetype' ) ) { function exif_imagetype ( $ filename ) { if ( ( list ( , , $ type ) = getimagesize ( $ filename ) ) !== false ) { return $ type ; } return false ; } } return in_array ( exif_imagetype ( $ this -> getPath ( ) ) , [ IMAGETYPE_GIF , IMAGETYPE_JPEG , IMAGETYPE_PNG , IMAGETYPE_BMP ] ) ; } catch ( \ Exception $ e ) { return false ; } }
Check by mimetype what file is image
19,431
public function listCommand ( $ services = [ ] , $ table_pattern = '' ) { foreach ( $ services ? : $ this -> _getDbServices ( ) as $ service ) { $ db = $ this -> _di -> getShared ( $ service ) ; $ this -> console -> writeLn ( [ 'service: `:service`' , 'service' => $ service ] , Console :: FC_CYAN ) ; foreach ( $ this -> _getTables ( $ service , $ table_pattern ) as $ row => $ table ) { $ columns = ( array ) $ db -> getMetadata ( $ table ) [ Db :: METADATA_ATTRIBUTES ] ; $ primaryKey = $ db -> getMetadata ( $ table ) [ Db :: METADATA_PRIMARY_KEY ] ; foreach ( $ columns as $ i => $ column ) { if ( in_array ( $ column , $ primaryKey , true ) ) { $ columns [ $ i ] = $ this -> console -> colorize ( $ column , Console :: FC_RED ) ; } } $ this -> console -> writeLn ( [ ' :row :table(:columns)' , 'row' => sprintf ( '%2d ' , $ row + 1 ) , 'table' => $ this -> console -> colorize ( $ table , Console :: FC_GREEN ) , 'columns' => implode ( ', ' , $ columns ) ] ) ; } } }
list databases and tables
19,432
public function modelCommand ( $ table , $ service = '' , $ namespace = 'App\Models' , $ optimized = false ) { if ( strpos ( $ namespace , '\\' ) === false ) { $ namespace = 'App\\' . ucfirst ( $ namespace ) . '\\Models' ; } if ( $ service ) { $ db = $ this -> _di -> getShared ( $ service ) ; if ( ! in_array ( $ table , $ db -> getTables ( ) , true ) ) { throw new Exception ( [ '`:table` is not exists' , 'table' => $ table ] ) ; } } else { foreach ( $ this -> _getDbServices ( ) as $ s ) { $ db = $ this -> _di -> getShared ( $ s ) ; if ( in_array ( $ table , $ db -> getTables ( ) , true ) ) { $ service = $ s ; break ; } } if ( ! $ service ) { throw new Exception ( [ '`:table` is not found in services`' , 'table' => $ table ] ) ; } } $ this -> console -> progress ( [ '`:table` processing...' , 'table' => $ table ] , '' ) ; $ plainClass = Text :: camelize ( $ table ) ; $ fileName = "@tmp/db_model/$plainClass.php" ; $ model_str = $ this -> _renderModel ( $ service , $ table , $ namespace , $ optimized ) ; $ this -> filesystem -> filePut ( $ fileName , $ model_str ) ; $ this -> console -> progress ( [ '`:table` table saved to `:file`' , 'table' => $ table , 'file' => $ fileName ] ) ; }
generate model file in online
19,433
public function modelsCommand ( $ services = [ ] , $ table_pattern = '' , $ namespace = 'App\Models' , $ optimized = false ) { if ( strpos ( $ namespace , '\\' ) === false ) { $ namespace = 'App\\' . ucfirst ( $ namespace ) . '\\Models' ; } foreach ( $ services ? : $ this -> _getDbServices ( ) as $ service ) { foreach ( $ this -> _getTables ( $ service , $ table_pattern ) as $ table ) { $ this -> console -> progress ( [ '`:table` processing...' , 'table' => $ table ] , '' ) ; $ plainClass = Text :: camelize ( $ table ) ; $ fileName = "@tmp/db_models/$plainClass.php" ; $ model_str = $ this -> _renderModel ( $ service , $ table , $ namespace , $ optimized ) ; $ this -> filesystem -> filePut ( $ fileName , $ model_str ) ; $ this -> console -> progress ( [ ' `:table` table saved to `:file`' , 'table' => $ table , 'file' => $ fileName ] ) ; } } }
generate models file in online
19,434
private function isMetadataFullyLoaded ( array $ metadata ) { return $ metadata [ ClassMetadata :: LOGIN_PROPERTY ] && $ metadata [ ClassMetadata :: PASSWORD_PROPERTY ] && $ metadata [ ClassMetadata :: API_KEY_PROPERTY ] && $ metadata [ ClassMetadata :: LAST_ACTION_PROPERTY ] ; }
Method which checks if all metadata annotations were loaded already .
19,435
public function decorateConfiguration ( \ Mmi \ Navigation \ NavigationConfig $ config ) { $ objectArray = ( new CmsCategoryQuery ) -> lang ( ) -> andFieldStatus ( ) -> equals ( \ Cms \ Orm \ CmsCategoryRecord :: STATUS_ACTIVE ) -> orderAscParentId ( ) -> orderAscOrder ( ) -> find ( ) -> toObjectArray ( ) ; foreach ( $ objectArray as $ key => $ record ) { if ( $ record -> parentId != 0 ) { continue ; } $ element = new \ Mmi \ Navigation \ NavigationConfigElement ( $ record -> uri ) ; $ this -> _setNavigationElementFromRecord ( $ record , $ element ) ; $ config -> addElement ( $ element ) ; unset ( $ objectArray [ $ key ] ) ; $ this -> _buildChildren ( $ record , $ element , $ objectArray ) ; } }
Dodaje do konfiguracji dane z bazy danych
19,436
protected function _setNavigationElementFromRecord ( CmsCategoryRecord $ record , \ Mmi \ Navigation \ NavigationConfigElement $ element ) { $ params = [ ] ; parse_str ( $ record -> mvcParams , $ params ) ; $ params [ 'uri' ] = $ record -> customUri ? $ record -> customUri : $ record -> uri ; $ config = $ record -> getConfig ( ) ; $ config -> typeId = $ record -> cmsCategoryTypeId ; $ config -> categoryId = $ record -> id ; $ element -> setModule ( 'cms' ) -> setController ( 'category' ) -> setAction ( 'dispatch' ) -> setParams ( $ params ) -> setBlank ( $ record -> blank ? true : false ) -> setDisabled ( $ record -> active ? false : true ) -> setHttps ( $ record -> https ) -> setUri ( $ record -> redirectUri ? : null ) -> setLabel ( $ record -> name ) -> setLang ( $ record -> lang ) -> setFollow ( $ record -> follow ? true : false ) -> setConfig ( $ config ) -> setDateStart ( $ record -> dateStart ) -> setDateEnd ( $ record -> dateEnd ) ; if ( $ record -> title ) { $ element -> setTitle ( $ record -> title ) ; } if ( $ record -> description ) { $ element -> setDescription ( $ record -> description ) ; } return $ this -> _setNavigationElementRoles ( $ record , $ element ) ; }
Ustawia dane elementu nawigacji na podstawie rekordu kategorii
19,437
public function render ( array $ options = array ( ) ) { $ url = $ this -> service -> generateEmbedUrl ( $ this ) ; $ options = array_replace ( array ( 'width' => 560 , 'height' => 315 , 'frameborder' => 0 , 'allowfullscreen' => '' ) , $ options ) ; $ html = <<<HTML<iframe src="$url" width="{$options['width']}" height="{$options['height']}" frameborder="{$options['frameborder']}" {$options['allowfullscreen']}></iframe>HTML ; return $ html ; }
Render the HTML for the embedded video player
19,438
public static function run ( ) { foreach ( Orm \ CmsCronQuery :: active ( ) -> find ( ) as $ cron ) { if ( ! self :: _getToExecute ( $ cron ) ) { continue ; } $ output = '' ; try { $ start = microtime ( true ) ; $ output = \ Mmi \ Mvc \ ActionHelper :: getInstance ( ) -> action ( new \ Mmi \ Http \ Request ( [ 'module' => $ cron -> module , 'controller' => $ cron -> controller , 'action' => $ cron -> action ] ) ) ; $ elapsed = round ( microtime ( true ) - $ start , 2 ) ; } catch ( \ Exception $ e ) { \ Mmi \ App \ FrontController :: getInstance ( ) -> getLogger ( ) -> error ( 'CRON failed: @' . gethostname ( ) . $ cron -> name . ' ' . $ e -> getMessage ( ) ) ; return ; } $ cron -> dateLastExecute = date ( 'Y-m-d H:i:s' ) ; \ App \ Registry :: $ db -> connect ( ) ; $ cron -> saveWithoutLastDateModify ( ) ; \ Mmi \ App \ FrontController :: getInstance ( ) -> getLogger ( ) -> info ( 'CRON done: @' . gethostname ( ) . ' ' . $ cron -> name . ' ' . $ output . ' in ' . $ elapsed . 's' ) ; } }
Pobiera zadania crona
19,439
protected static function _getToExecute ( $ record ) { return self :: _valueMatch ( date ( 'i' ) , $ record -> minute ) && self :: _valueMatch ( date ( 'H' ) , $ record -> hour ) && self :: _valueMatch ( date ( 'd' ) , $ record -> dayOfMonth ) && self :: _valueMatch ( date ( 'm' ) , $ record -> month ) && self :: _valueMatch ( date ( 'N' ) , $ record -> dayOfWeek ) ; }
Sprawdza czy dane zadanie jest do wykonania
19,440
public function indexAction ( ) { $ oid = new ObjectIdentity ( 'class' , 'FOM\UserBundle\Entity\Group' ) ; $ query = $ this -> getDoctrine ( ) -> getManager ( ) -> createQuery ( 'SELECT g FROM FOMUserBundle:Group g' ) ; $ groups = $ query -> getResult ( ) ; $ allowed_groups = array ( ) ; foreach ( $ groups as $ index => $ group ) { if ( $ this -> get ( 'security.authorization_checker' ) -> isGranted ( 'VIEW' , $ group ) ) { $ allowed_groups [ ] = $ group ; } } return array ( 'groups' => $ allowed_groups , 'create_permission' => $ this -> get ( 'security.authorization_checker' ) -> isGranted ( 'CREATE' , $ oid ) ) ; }
Renders group list .
19,441
public static function getInstance ( DriverConfig $ config ) { $ pdoDriver = PdoDriverFactory :: getInstance ( ) ; return new OracleMetaDataDAO ( $ pdoDriver -> getConnection ( $ config ) ) ; }
Create PDO Metadata DAO instance
19,442
public function getSource ( $ sourceName = null ) { if ( $ sourceName === 'default' ) { $ sourceName = null ; } foreach ( $ this -> sources as $ key => $ item ) { if ( ( ! $ sourceName || $ sourceName === $ key ) ) { return $ item ; } $ source = $ item !== $ this ? $ item -> getSource ( $ sourceName ) : null ; if ( $ source ) { return $ source ; } } if ( $ sourceName ) { return null ; } return $ this ; }
Get source by name
19,443
public static function getRootFolder ( ) { $ filesystem = new Filesystem ( ) ; $ folder = $ filesystem -> normalizePath ( __DIR__ . '/../' ) ; if ( ! is_dir ( $ folder ) ) { throw new RuntimeException ( sprintf ( 'Could not find a matching folder for folder name "%1$s".' , $ folder ) ) ; } return $ folder ; }
Get the path to the package s root folder .
19,444
public static function getFile ( $ fileName ) { $ filesystem = new Filesystem ( ) ; $ file = $ filesystem -> normalizePath ( __DIR__ . '/../' . $ fileName ) ; if ( ! file_exists ( $ file ) ) { throw new RuntimeException ( sprintf ( 'Could not find a matching file for file name "%1$s".' , $ fileName ) ) ; } return $ file ; }
Get a file path from a project - root - relative file name .
19,445
public function create ( $ serviceId ) { try { return $ this -> container -> get ( $ serviceId , Container :: NULL_ON_INVALID_REFERENCE ) ; } catch ( \ Exception $ e ) { if ( $ this -> isCausedBySyntheticServiceRequest ( $ e ) ) { return null ; } throw new CannotInstantiateServiceException ( $ serviceId , 0 , $ e ) ; } }
Creates the service with the given ID .
19,446
protected function isCausedBySyntheticServiceRequest ( \ Exception $ exception ) { if ( ! ( $ exception instanceof RuntimeException ) ) { return false ; } return strpos ( $ exception -> getMessage ( ) , 'requested a synthetic service' ) !== false ; }
Checks if a request for a synthetic service caused the provided exception .
19,447
protected function _addRoute ( $ pattern , $ paths = null , $ method = null ) { $ route = new Route ( $ pattern , $ paths , $ method ) ; if ( $ method !== 'REST' && strpos ( $ pattern , '{' ) === false ) { $ this -> _simple_routes [ $ method ] [ $ pattern ] = $ route ; } else { $ this -> _regex_routes [ ] = $ route ; } return $ route ; }
Adds a route applying the common attributes
19,448
public function add ( $ pattern , $ paths = null , $ method = null ) { return $ this -> _addRoute ( $ pattern , $ paths , $ method ) ; }
Adds a route to the router on any HTTP method
19,449
public function authenticateToken ( TokenInterface $ token , UserProviderInterface $ userProvider , $ providerKey ) { $ apiKey = $ token -> getCredentials ( ) ; $ user = $ this -> om -> getRepository ( $ this -> modelName ) -> findOneBy ( array ( $ this -> metadata -> getPropertyName ( ClassMetadata :: API_KEY_PROPERTY ) => ( string ) $ apiKey ) ) ; if ( ! $ user ) { $ this -> dispatcher -> dispatch ( Ma27ApiKeyAuthenticationEvents :: FIREWALL_FAILURE , new OnFirewallFailureEvent ( ) ) ; throw new AuthenticationException ( sprintf ( 'API key %s does not exist!' , $ apiKey ) ) ; } $ token = new PreAuthenticatedToken ( $ user , $ apiKey , $ providerKey , $ user -> getRoles ( ) ? : array ( ) ) ; $ firewallEvent = new OnFirewallAuthenticationEvent ( $ user ) ; $ firewallEvent -> setToken ( $ token ) ; $ this -> dispatcher -> dispatch ( Ma27ApiKeyAuthenticationEvents :: FIREWALL_LOGIN , $ firewallEvent ) ; return $ token ; }
Returns an authenticated token .
19,450
public function createToken ( Request $ request , $ providerKey ) { $ apiKey = $ request -> headers -> get ( $ this -> header ) ; if ( ! $ apiKey ) { throw new BadCredentialsException ( 'No ApiKey found in request!' ) ; } return new PreAuthenticatedToken ( 'unauthorized' , $ apiKey , $ providerKey ) ; }
Creates an api key by the http request .
19,451
public static function getInstance ( ) { $ classAwake = new ClassAwake ( ) ; $ viewHelpers = $ classAwake -> wakeByInterfaces ( array ( __DIR__ , ) , 'CrudGenerator\View\ViewHelperFactoryInterface' ) ; return new View ( new ViewRenderer ( $ viewHelpers ) ) ; }
Build a View manager
19,452
public function deleteAttributeRelationAction ( ) { $ record = ( new \ Cms \ Orm \ CmsAttributeRelationQuery ) -> whereObjectId ( ) -> equals ( $ this -> id ) -> findPk ( $ this -> relationId ) ; if ( $ record && $ record -> delete ( ) ) { foreach ( ( new \ Cms \ Orm \ CmsCategoryQuery ) -> whereCmsCategoryTypeId ( ) -> equals ( $ this -> id ) -> findPairs ( 'id' , 'id' ) as $ categoryId ) { ( new \ Cms \ Model \ AttributeValueRelationModel ( 'category' , $ categoryId ) ) -> deleteAttributeValueRelationsByAttributeId ( $ record -> cmsAttributeId ) ; } $ this -> getMessenger ( ) -> addMessage ( 'messenger.attribute.attributeRelation.deleted' , true ) ; } }
Usuwanie relacji szablon atrybut
19,453
public function verify ( $ data , array $ callbacks = [ ] , $ cast = '' ) { if ( empty ( $ callbacks ) === true ) { return $ this -> fields [ $ cast ] = $ data ; } $ isValid = function ( $ data ) use ( $ callbacks , $ cast ) { if ( empty ( $ cast ) === false ) { $ this -> cast = $ cast ; } foreach ( $ callbacks as $ callback ) { $ this -> { $ callback } ( $ data ) ; } } ; return $ isValid ( $ data ) ; }
Verify transferred according to the rules
19,454
public function setLength ( array $ condition ) { if ( is_array ( $ condition ) === true ) { $ this -> { key ( $ condition ) } = ( int ) current ( $ condition ) ; } return $ this ; }
Set value length for the search min and max
19,455
protected function isNotNull ( $ value ) { if ( is_null ( $ value ) === true || empty ( $ value ) === true ) { throw new ExceptionFactory ( 'DataType' , [ $ value , 'string' ] ) ; } return true ; }
Verify by not null
19,456
protected function isAcceptLength ( $ value ) { $ value = strlen ( utf8_decode ( $ value ) ) ; if ( $ value < $ this -> min ) { throw new ExceptionFactory ( 'InvalidLength' , [ $ value , 'greater' , $ this -> min ] ) ; } else if ( $ value > $ this -> max ) { throw new ExceptionFactory ( 'InvalidLength' , [ $ value , 'less' , $ this -> max ] ) ; } return true ; }
Verify by length
19,457
protected function isExists ( array $ value ) { foreach ( $ value as $ table => $ fields ) { if ( $ this -> isModel ( $ table ) === true ) { $ model = ( new Manager ( ) ) -> load ( $ table , new $ table ) ; $ this -> validColumns ( $ model -> getModelsMetaData ( ) , $ fields , $ table , $ model ) ; $ columnDefines = ( new $ table ) -> getReadConnection ( ) -> describeColumns ( $ model -> getSource ( ) ) ; $ this -> fields [ 'tables' ] [ $ model -> getSource ( ) ] = $ table ; foreach ( $ columnDefines as $ column ) { if ( in_array ( $ column -> getName ( ) , $ fields ) === true ) { $ this -> validTypes ( $ column ) ; $ this -> fields [ $ this -> cast ] [ $ model -> getSource ( ) ] [ $ column -> getName ( ) ] = $ column -> getType ( ) ; } } } } return true ; }
Check if field exist in table
19,458
protected function isOrdered ( array $ ordered ) { foreach ( $ ordered as $ table => $ sort ) { if ( $ this -> isModel ( $ table ) === true ) { $ model = ( new Manager ( ) ) -> load ( $ table , new $ table ) ; $ this -> validColumns ( $ model -> getModelsMetaData ( ) , array_keys ( $ sort ) , $ table , $ model ) ; $ sort = array_map ( 'strtolower' , $ sort ) ; if ( empty ( $ diff = array_diff ( array_values ( $ sort ) , $ this -> sort ) ) === false ) { throw new ExceptionFactory ( 'Column' , [ 'ORDER_TYPES_DOES_NOT_EXISTS' , $ diff ] ) ; } if ( empty ( $ diff = array_diff ( $ sort , $ this -> sort ) ) === false ) { throw new ExceptionFactory ( 'Column' , [ 'ORDER_TYPES_DOES_NOT_EXISTS' , $ diff ] ) ; } $ this -> fields [ $ this -> cast ] [ $ model -> getSource ( ) ] = $ sort ; } } return true ; }
Check ordered fields
19,459
protected function validTypes ( Column $ column ) { if ( in_array ( $ column -> getType ( ) , $ this -> columns ) === false ) { throw new ExceptionFactory ( 'Column' , [ 'COLUMN_DOES_NOT_SUPPORT' , $ column -> getType ( ) , $ column -> getName ( ) ] ) ; } return true ; }
Check if field type support in table
19,460
protected function validColumns ( Memory $ meta , array $ columns , $ table , $ model ) { if ( empty ( $ not = array_diff ( $ columns , $ meta -> getAttributes ( $ model ) ) ) === false ) { throw new ExceptionFactory ( 'Column' , [ 'COLUMN_DOES_NOT_EXISTS' , $ not , $ table , $ meta -> getAttributes ( $ model ) ] ) ; } return true ; }
Validate table columns
19,461
public function findAll ( ) { if ( $ this -> fileManager -> isDir ( Installer :: BASE_PATH . self :: HISTORY_PATH ) === false ) { throw new EnvironnementResolverException ( sprintf ( 'Unable to locate "%d"' , Installer :: BASE_PATH . self :: HISTORY_PATH ) ) ; } $ historyCollection = new HistoryCollection ( ) ; $ searchPath = Installer :: BASE_PATH . self :: HISTORY_PATH . '*' . self :: FILE_EXTENSION ; foreach ( $ this -> fileManager -> glob ( $ searchPath ) as $ file ) { $ content = $ this -> fileManager -> fileGetContent ( $ file ) ; try { $ historyCollection -> append ( $ this -> historyHydrator -> jsonToDTO ( $ content ) ) ; } catch ( InvalidHistoryException $ e ) { continue ; } } return $ historyCollection ; }
Retrieve all history
19,462
public function indexAction ( ) { $ allowed_users = array ( ) ; $ users = $ this -> getDoctrine ( ) -> getManager ( ) -> createQuery ( 'SELECT r FROM FOMUserBundle:User r' ) -> getResult ( ) ; foreach ( $ users as $ index => $ user ) { if ( $ this -> isGranted ( 'VIEW' , $ user ) ) { $ allowed_users [ ] = $ user ; } } $ oid = new ObjectIdentity ( 'class' , 'FOM\UserBundle\Entity\User' ) ; return array ( 'users' => $ allowed_users , 'create_permission' => $ this -> isGranted ( 'CREATE' , $ oid ) ) ; }
Renders user list .
19,463
protected function addPolicyHeader ( ResponseInterface $ response ) { $ this -> loadDefaultProfiles ( ) ; $ currentHeader = $ response -> getHeader ( $ this -> header ) ; $ initialConfig = [ ] ; if ( count ( $ currentHeader ) ) { $ initialConfig = $ this -> decodeConfiguration ( $ currentHeader [ 0 ] ) ; } $ initialDirectives = $ this -> encodeConfiguration ( $ initialConfig ) ; $ this -> mergeProfileWithConfig ( $ initialConfig ) ; $ newDirectives = $ this -> encodeConfiguration ( $ this -> config ) ; if ( $ newDirectives != $ initialDirectives ) { $ response = $ response -> withHeader ( $ this -> header , $ newDirectives ) ; } return $ response ; }
Add content security policy header to response
19,464
protected function decodeConfiguration ( $ string ) { $ config = [ ] ; $ directives = explode ( $ this -> directiveSeparator , $ string ) ; foreach ( $ directives as $ directive ) { $ parts = array_filter ( explode ( $ this -> sourceSeparator , $ directive ) ) ; $ key = trim ( array_shift ( $ parts ) ) ; $ config [ $ key ] = $ parts ; } return $ config ; }
Decode a given string into configuration
19,465
protected function encodeConfiguration ( $ config = [ ] ) { $ value = [ ] ; ksort ( $ config ) ; foreach ( $ config as $ directive => $ values ) { $ values = array_unique ( $ values ) ; sort ( $ values ) ; array_unshift ( $ values , $ directive ) ; $ string = implode ( $ this -> sourceSeparator , $ values ) ; if ( $ string ) { $ value [ ] = $ string ; } } return implode ( $ this -> directiveSeparator . ' ' , $ value ) ; }
Encode the current configuration as string
19,466
protected function getArrayFromValue ( $ value , $ separator = ',' ) { if ( ! is_array ( $ value ) ) { $ value = explode ( $ separator , $ value ) ; } return $ value ; }
Create array from value
19,467
protected function loadDefaultProfiles ( ) { $ defaultProfiles = [ ] ; if ( isset ( $ this -> profiles [ 'default' ] ) ) { $ defaultProfiles = $ this -> getArrayFromValue ( $ this -> profiles [ 'default' ] ) ; } array_map ( [ $ this , 'loadProfileByKey' ] , $ defaultProfiles ) ; }
Load default profiles
19,468
protected function loadProfileByKey ( $ key ) { if ( isset ( $ this -> profiles [ 'profiles' ] [ $ key ] ) ) { $ profile = $ this -> profiles [ 'profiles' ] [ $ key ] ; if ( is_array ( $ profile ) ) { $ this -> mergeProfileWithConfig ( $ profile ) ; } } }
Load a specific profile
19,469
protected function mergeProfileWithConfig ( array $ profile ) { foreach ( $ profile as $ directive => $ values ) { if ( ! isset ( $ this -> config [ $ directive ] ) ) { $ this -> config [ $ directive ] = [ ] ; } $ values = $ this -> getArrayFromValue ( $ values ) ; $ this -> config [ $ directive ] = array_merge ( $ this -> config [ $ directive ] , $ values ) ; } }
Merge a given profile with current configuration
19,470
public function getValue ( ) { $ arr = [ ] ; if ( ! is_array ( $ this -> _options [ 'value' ] ) ) { return [ ] ; } foreach ( $ this -> _options [ 'value' ] as $ key ) { $ arr [ $ key ] = $ key ; } return $ arr ; }
przerobienie tablicy + klucz
19,471
public function moveTo ( $ dst , $ allowedExtensions = 'jpg,jpeg,png,gif,doc,xls,pdf,zip' , $ overwrite = false ) { if ( $ allowedExtensions !== '*' ) { $ extension = pathinfo ( $ dst , PATHINFO_EXTENSION ) ; if ( ! $ extension || preg_match ( "#\b$extension\b#" , $ allowedExtensions ) !== 1 ) { throw new FileException ( [ '`:extension` file type is not allowed upload' , 'extension' => $ extension ] ) ; } } if ( $ this -> _file [ 'error' ] !== UPLOAD_ERR_OK ) { throw new FileException ( [ 'error code of upload file is not UPLOAD_ERR_OK: :error' , 'error' => $ this -> _file [ 'error' ] ] ) ; } if ( $ this -> filesystem -> fileExists ( $ dst ) ) { if ( $ overwrite ) { $ this -> filesystem -> fileDelete ( $ dst ) ; } else { throw new FileException ( [ '`:file` file already exists' , 'file' => $ dst ] ) ; } } $ this -> filesystem -> dirCreate ( dirname ( $ dst ) ) ; if ( ! move_uploaded_file ( $ this -> _file [ 'tmp_name' ] , $ this -> alias -> resolve ( $ dst ) ) ) { throw new FileException ( [ 'move_uploaded_file to `:dst` failed: :last_error_message' , 'dst' => $ dst ] ) ; } if ( ! chmod ( $ this -> alias -> resolve ( $ dst ) , 0644 ) ) { throw new FileException ( [ 'chmod `:dst` destination failed: :last_error_message' , 'dst' => $ dst ] ) ; } }
Moves the temporary file to a destination within the application
19,472
public function getExtension ( ) { $ name = $ this -> _file [ 'name' ] ; return ( $ extension = pathinfo ( $ name , PATHINFO_EXTENSION ) ) === $ name ? '' : $ extension ; }
Returns the file extension
19,473
public function select ( string $ type = null ) { if ( empty ( $ type ) ) { $ type = $ this -> provider ; } $ providers = $ this -> mergeProviders ( ) ; if ( ! isset ( $ providers [ $ type ] ) ) { throw new InvalidArgumentException ( sprintf ( 'Provider %s does not exist' , $ type ) ) ; } $ providerBeanName = $ providers [ $ type ] ; return App :: getBean ( $ providerBeanName ) ; }
Select a provider by Selector
19,474
public function staticPhp ( $ text ) { $ textExplode = explode ( '->' , $ text ) ; $ variableName = str_replace ( '$' , '' , array_shift ( $ textExplode ) ) ; $ variableVariable = $ this -> variables ; if ( isset ( $ variableVariable [ $ variableName ] ) === false ) { throw new \ InvalidArgumentException ( sprintf ( 'variable %s does not exist' , $ variableName ) ) ; } $ textExplode = array_map ( function ( $ value ) { return str_replace ( '()' , '' , $ value ) ; } , $ textExplode ) ; $ instance = $ variableVariable [ $ variableName ] ; $ keys = array_values ( $ textExplode ) ; $ lastKey = array_pop ( $ keys ) ; foreach ( $ textExplode as $ key => $ method ) { if ( $ instance === null && $ lastKey !== $ key ) { throw new \ InvalidArgumentException ( sprintf ( 'method %s return null' , $ method ) ) ; } elseif ( false === method_exists ( $ instance , $ method ) ) { throw new \ InvalidArgumentException ( sprintf ( 'method %s does not exist on %s' , $ method , $ text ) ) ; } else { $ instance = $ instance -> $ method ( ) ; } } return $ instance ; }
Interpret a php plain text
19,475
protected function setKeyInEnvironmentFile ( $ key ) { $ currentContent = file_get_contents ( base_path ( '.env' ) ) ; $ currentValue = '' ; if ( preg_match ( '/^GLIDE_SIGN_KEY=(.*)$/m' , $ currentContent , $ matches ) && isset ( $ matches [ 1 ] ) ) { $ currentValue = $ matches [ 1 ] ; } file_put_contents ( base_path ( '.env' ) , str_replace ( 'GLIDE_SIGN_KEY=' . $ currentValue , 'GLIDE_SIGN_KEY=' . $ key , $ currentContent ) ) ; }
Set the key in the environment file .
19,476
public function defaultCommand ( $ ip = '127.0.0.1' , $ port = 1983 ) { $ router_str = <<<'STR'<?php$_SERVER['SERVER_ADDR'] = ':ip';$_SERVER['SERVER_PORT'] = ':port';$_SERVER['REQUEST_SCHEME'] = 'http';chdir('public');$uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));if ($uri !== '/') { if (file_exists('public/' . $uri) || preg_match('#\.(?:css|js|gif|png|jpg|jpeg|ttf|woff|ico)$#', $uri) === 1 ) { return false; }}$_GET['_url'] = $uri;$_REQUEST['_url'] = $uri;require_once 'index.php';STR ; if ( $ value = $ this -> arguments -> getValue ( 0 ) ) { if ( strpos ( $ value , ':' ) ) { list ( $ ip , $ port ) = explode ( ':' , $ value , 2 ) ; } elseif ( is_numeric ( $ value ) ) { $ port = ( int ) $ value ; } else { $ ip = $ value ; } } $ router = 'builtin_server_router.php' ; $ this -> filesystem -> filePut ( "@tmp/$router" , strtr ( $ router_str , [ ':ip' => $ ip , ':port' => $ port ] ) ) ; echo "server listen on: $ip:$port" , PHP_EOL ; $ prefix = $ this -> router -> getPrefix ( ) ; if ( DIRECTORY_SEPARATOR === '\\' ) { shell_exec ( "explorer.exe http://$ip:$port" . $ prefix ) ; } shell_exec ( "php -S $ip:$port -t public tmp/$router" ) ; }
start with php builtin server
19,477
public function getIterator ( ) { $ this -> kernel -> boot ( ) ; $ viewDirectories = $ this -> getPossibleViewDirectories ( ) ; $ viewDirectories = $ this -> removeNotExistingDirectories ( $ viewDirectories ) ; $ templates = $ this -> getTwigTemplatesIn ( $ viewDirectories ) ; return new \ ArrayIterator ( $ templates ) ; }
Returns an iterator that provides Twig template paths .
19,478
protected function getTwigTemplatesIn ( $ directories ) { if ( count ( $ directories ) === 0 ) { return array ( ) ; } $ templates = Finder :: create ( ) -> in ( $ directories ) -> files ( ) -> name ( '*.*.twig' ) ; $ templates = iterator_to_array ( $ templates , false ) ; $ templates = array_map ( function ( SplFileInfo $ file ) { return $ file -> getRealPath ( ) ; } , $ templates ) ; return $ templates ; }
Returns the paths to all Twig templates in the given directories .
19,479
public function findWidgetRelationById ( $ id ) { foreach ( $ this -> _widgetCollection as $ widgetRelationRecord ) { if ( $ widgetRelationRecord -> id == $ id ) { return $ widgetRelationRecord ; } } }
Pobiera rekord konfiguracji widgeta
19,480
protected function trigger_error ( $ code , $ message , $ type = E_USER_NOTICE ) { $ trace = debug_backtrace ( ) ; $ Err = PLUG :: raise_error ( $ code , $ message , $ type , $ trace ) ; $ this -> on_trigger_error ( $ Err ) ; }
Raise a PLUGError originating from this instance .
19,481
function get_error_level ( ) { $ e = 0 ; foreach ( $ this -> err_stack as $ t => $ ids ) { foreach ( $ ids as $ id ) { $ Err = PLUGError :: get_reference ( $ t , $ id ) ; if ( is_object ( $ Err ) ) { $ e |= $ t ; break ; } } } return $ e ; }
Get current level of errors raised in this object .
19,482
function get_errors ( $ emask = null ) { $ errs = array ( ) ; foreach ( $ this -> err_stack as $ t => $ ids ) { if ( $ emask !== NULL && ( $ emask & $ t ) == 0 ) { continue ; } foreach ( $ ids as $ id ) { $ Err = PLUGError :: get_reference ( $ t , $ id ) ; if ( is_object ( $ Err ) ) { $ errs [ ] = $ Err ; } } } return $ errs ; }
Get errors raised in this object .
19,483
function clear_errors ( $ emask = null ) { foreach ( $ this -> err_stack as $ t => $ ids ) { if ( $ emask !== NULL && ( $ emask & $ t ) == 0 ) { continue ; } foreach ( $ ids as $ id ) { $ Err = PLUGError :: get_reference ( $ t , $ id ) ; $ Err -> clear ( ) ; } unset ( $ this -> err_stack [ $ t ] ) ; } }
Clear errors raised in this object .
19,484
function dump_errors ( $ emask = null ) { foreach ( $ this -> err_stack as $ t => $ ids ) { if ( $ emask !== NULL && ( $ emask & $ t ) == 0 ) { continue ; } foreach ( $ ids as $ id ) { $ Err = PLUGError :: get_reference ( $ t , $ id ) ; echo ( string ) $ Err ; echo $ Err -> getTraceAsString ( ) , "\n" ; } } }
Dump errors raised in this object .
19,485
function is_error ( $ emask = null ) { $ e = $ this -> get_error_level ( ) ; if ( $ emask === null ) { return ( bool ) $ e ; } else { return ( bool ) ( $ e & $ emask ) ; } }
Test whether this object is in a state of error
19,486
public function getAllMetadata ( ) { $ configName = ( $ this -> config !== null ) ? $ this -> config -> getUniqueName ( ) : '' ; $ cacheFilename = Installer :: BASE_PATH . Installer :: CACHE_PATH . DIRECTORY_SEPARATOR ; $ cacheFilename .= md5 ( 'all_metadata' . get_class ( $ this -> metadataDAO ) . $ configName ) ; if ( $ this -> fileManager -> isFile ( $ cacheFilename ) === true && $ this -> noCache === false ) { $ data = unserialize ( $ this -> fileManager -> fileGetContent ( $ cacheFilename ) ) ; } else { $ data = $ this -> metadataDAO -> getAllMetadata ( ) ; $ this -> fileManager -> filePutsContent ( $ cacheFilename , serialize ( $ data ) ) ; } return $ data ; }
Get all metadata from the concrete metadata DAO
19,487
function defined ( $ c ) { if ( isset ( $ this -> literals [ $ c ] ) ) { return true ; } if ( ! defined ( $ c ) ) { return false ; } $ i = constant ( $ c ) ; return isset ( $ this -> names [ $ i ] ) && $ this -> names [ $ i ] === $ c ; }
Test if symbol is defined in this Lex
19,488
function name ( $ i ) { if ( is_int ( $ i ) ) { if ( ! isset ( $ this -> names [ $ i ] ) ) { trigger_error ( "symbol " . var_export ( $ i , 1 ) . " is unknown in " . get_class ( $ this ) , E_USER_NOTICE ) ; return 'UNKNOWN' ; } else { return $ this -> names [ $ i ] ; } } else if ( ! isset ( $ this -> literals [ $ i ] ) ) { trigger_error ( "literal symbol " . var_export ( $ i , 1 ) . " is unknown in " . get_class ( $ this ) , E_USER_NOTICE ) ; } return $ i ; }
Get internal name from constant symbol value
19,489
function export ( ) { $ RootSet = $ this -> resolve ( ) ; $ table = array ( ) ; $ RootSet -> export ( $ table , $ this -> Grammar ) ; return new LRParseTableBuilder ( $ table ) ; }
Export to determinsitic parse table .
19,490
function resolve ( ) { LRState :: clear_index ( ) ; LRStation :: clear_index ( ) ; return LRStateSet :: init ( $ this -> etransitions [ 0 ] , $ this -> Grammar ) ; }
Resolve non - deterministic automaton into a deterministic state tree
19,491
public function getAllAdapters ( ) { $ classCollection = $ this -> classAwake -> wakeByInterfaces ( array ( __DIR__ . '/Sources/' , ) , 'CrudGenerator\Metadata\Sources\MetaDataDAOFactoryInterface' ) ; $ adapterCollection = new MetaDataSourceCollection ( ) ; foreach ( $ classCollection as $ className ) { $ adapterCollection -> append ( $ this -> metaDataSourceHydrator -> adapterNameToMetaDataSource ( $ className ) ) ; } return $ adapterCollection ; }
Find all adpater in the projects
19,492
public function purgeQueue ( $ name ) { if ( ! isset ( $ this -> _queues [ $ name ] ) ) { throw new InvalidKeyException ( [ 'purge `:queue` queue failed: it is NOT exists' , 'queue' => $ name ] ) ; } try { $ this -> _queues [ $ name ] -> purge ( ) ; } catch ( \ Exception $ e ) { throw new AmqpException ( [ 'purge `:queue` queue failed: error' , 'queue' => $ name , 'error' => $ e -> getMessage ( ) ] ) ; } return $ this ; }
Purge the contents of a queue
19,493
public function getFieldTypes ( ) { static $ cached = [ ] ; $ class = static :: class ; if ( ! isset ( $ cached [ $ class ] ) ) { if ( ! $ doc = static :: sample ( ) ) { if ( ! $ docs = $ this -> getConnection ( ) -> fetchAll ( $ this -> getSource ( ) , [ ] , [ 'limit' => 1 ] ) ) { throw new RuntimeException ( [ '`:collection` collection has none record' , 'collection' => $ this -> getSource ( ) ] ) ; } $ doc = $ docs [ 0 ] ; } $ types = [ ] ; foreach ( $ doc as $ field => $ value ) { $ type = gettype ( $ value ) ; if ( $ type === 'integer' ) { $ types [ $ field ] = 'int' ; } elseif ( $ type === 'string' ) { $ types [ $ field ] = 'string' ; } elseif ( $ type === 'double' ) { $ types [ $ field ] = 'float' ; } elseif ( $ type === 'boolean' ) { $ types [ $ field ] = 'bool' ; } elseif ( $ type === 'array' ) { $ types [ $ field ] = 'array' ; } elseif ( $ value instanceof ObjectID ) { if ( $ field === '_id' ) { continue ; } $ types [ $ field ] = 'objectid' ; } else { throw new RuntimeException ( [ '`:field` field value type can not be infered.' , 'field' => $ field ] ) ; } } $ cached [ $ class ] = $ types ; } return $ cached [ $ class ] ; }
bool int float string array objectid
19,494
public function registerNamespaces ( $ namespaces , $ merge = true ) { foreach ( $ namespaces as $ namespace => $ path ) { $ path = rtrim ( $ path , '\\/' ) ; if ( DIRECTORY_SEPARATOR === '\\' ) { $ namespaces [ $ namespace ] = strtr ( $ path , '\\' , '/' ) ; } } $ this -> _namespaces = $ merge ? array_merge ( $ this -> _namespaces , $ namespaces ) : $ namespaces ; return $ this ; }
Register namespaces and their related directories
19,495
public function registerClasses ( $ classes , $ merge = true ) { if ( DIRECTORY_SEPARATOR === '\\' ) { foreach ( $ classes as $ key => $ path ) { $ classes [ $ key ] = strtr ( $ path , '\\' , '/' ) ; } } $ this -> _classes = $ merge ? array_merge ( $ this -> _classes , $ classes ) : $ classes ; return $ this ; }
Register classes and their locations
19,496
public function requireFile ( $ file ) { if ( PHP_EOL !== "\n" && strpos ( $ file , 'phar://' ) !== 0 ) { $ realPath = strtr ( realpath ( $ file ) , '\\' , '/' ) ; if ( $ realPath !== $ file ) { trigger_error ( "File name ($realPath) case mismatch for .$file" , E_USER_ERROR ) ; } } require $ file ; }
If a file exists require it from the file system .
19,497
public function load ( $ className ) { if ( isset ( $ this -> _classes [ $ className ] ) ) { $ file = $ this -> _classes [ $ className ] ; if ( ! is_file ( $ file ) ) { trigger_error ( strtr ( 'load `:class` class failed: `:file` is not exists.' , [ ':class' => $ className , ':file' => $ file ] ) , E_USER_ERROR ) ; } if ( PHP_EOL === "\n" || $ file [ 0 ] === 'p' ) { require $ file ; } else { $ this -> requireFile ( $ file ) ; } return true ; } foreach ( $ this -> _namespaces as $ namespace => $ path ) { if ( strpos ( $ className , $ namespace ) !== 0 ) { continue ; } $ file = $ path . strtr ( substr ( $ className , strlen ( $ namespace ) ) , '\\' , '/' ) . '.php' ; if ( is_file ( $ file ) ) { if ( PHP_EOL === "\n" || $ file [ 0 ] === 'p' ) { require $ file ; } else { $ this -> requireFile ( $ file ) ; } return true ; } } return false ; }
Makes the work of autoload registered classes
19,498
public function transform ( $ ace ) { $ sid = null ; $ mask = null ; $ sidPrefix = '' ; $ sidName = '' ; $ permissions = array ( ) ; if ( $ ace instanceof Entry ) { $ sid = $ ace -> getSecurityIdentity ( ) ; $ mask = $ ace -> getMask ( ) ; } elseif ( is_array ( $ ace ) ) { $ sid = $ ace [ 'sid' ] ; $ mask = $ ace [ 'mask' ] ; } $ sidString = '' ; if ( $ sid instanceof RoleSecurityIdentity ) { $ sidPrefix = 'r' ; $ sidName = $ sid -> getRole ( ) ; $ sidString = sprintf ( '%s:%s' , $ sidPrefix , $ sidName ) ; } elseif ( $ sid instanceof UserSecurityIdentity ) { $ sidPrefix = 'u' ; $ sidName = $ sid -> getUsername ( ) ; $ sidClass = $ sid -> getClass ( ) ; $ sidString = sprintf ( '%s:%s:%s' , $ sidPrefix , $ sidName , $ sidClass ) ; } for ( $ i = 1 ; $ i <= 30 ; $ i ++ ) { $ key = 1 << ( $ i - 1 ) ; if ( $ mask & $ key ) { $ permissions [ $ i ] = true ; } else { $ permissions [ $ i ] = false ; } } return array ( 'sid' => $ sidString , 'permissions' => $ permissions ) ; }
Transforms an single ACE to an object suitable for ACEType
19,499
public function reverseTransform ( $ data ) { $ sidParts = explode ( ':' , $ data [ 'sid' ] ) ; if ( strtoupper ( $ sidParts [ 0 ] ) == 'R' ) { $ sid = new RoleSecurityIdentity ( $ sidParts [ 1 ] ) ; } else { if ( 3 == count ( $ sidParts ) ) { $ class = $ sidParts [ 2 ] ; } else { if ( $ this -> isLdapUser ( $ sidParts [ 1 ] ) ) { $ class = 'Mapbender\LdapIntegrationBundle\Entity\LdapUser' ; } else { $ class = 'FOM\UserBundle\Entity\User' ; } } $ sid = new UserSecurityIdentity ( $ sidParts [ 1 ] , $ class ) ; } $ maskBuilder = new MaskBuilder ( ) ; foreach ( $ data [ 'permissions' ] as $ bit => $ permission ) { if ( true === $ permission ) { $ maskBuilder -> add ( 1 << ( $ bit - 1 ) ) ; } } return array ( 'sid' => $ sid , 'mask' => $ maskBuilder -> get ( ) ) ; }
Transforms an ACEType result into an ACE