idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
35,400
protected function filterLocale ( Locale $ locale ) { $ language = substr ( $ locale -> locale , 0 , 2 ) ; $ this -> addLocale ( $ locale -> locale ) ; $ this -> addLocale ( $ language ) ; }
Filter the given Locale .
35,401
public function deleteStoredObjectAttribute ( $ objectAttribute , $ version = null ) { if ( $ version === null ) { $ this -> storage -> deleteFieldData ( $ objectAttribute , $ version ) ; } }
Deletes the object attribute .
35,402
public function fetchObjectAttributeHTTPInput ( $ http , $ base , $ objectAttribute ) { $ productId = $ this -> getProductIdFromInput ( $ http , $ base , $ objectAttribute ) ; $ objectAttribute -> setContent ( $ this -> fieldType -> fromHash ( $ productId ) ) ; return true ; }
Fetches the HTTP input for the content object attribute .
35,403
protected function getProductIdFromInput ( $ http , $ base , $ objectAttribute ) { return ( int ) $ http -> postVariable ( $ base . '_data_product_id_' . $ objectAttribute -> attribute ( 'id' ) ) ; }
Fetches the product ID from HTTP input for the content object attribute .
35,404
public function objectDisplayInformation ( $ objectAttribute , $ mergeInfo = false ) { $ info = array ( 'edit' => array ( 'grouped_input' => true , ) , 'view' => array ( 'grouped_input' => true , ) , ) ; return parent :: objectDisplayInformation ( $ objectAttribute , $ info ) ; }
Will return information on how the datatype should be represented in the various display modes when used by an object .
35,405
public function addPath ( string $ path , string $ namespace = null ) : void { if ( ! $ namespace ) { $ this -> template -> addLocation ( $ path ) ; return ; } $ this -> template -> addNamespace ( $ namespace , $ path ) ; }
Add a path for template
35,406
public function getPaths ( ) : array { $ templatePaths = [ ] ; $ paths = $ this -> template -> getFinder ( ) -> getPaths ( ) ; $ hints = $ this -> template -> getFinder ( ) -> getHints ( ) ; foreach ( $ paths as $ path ) { $ templatePaths [ ] = new TemplatePath ( $ path ) ; } foreach ( $ hints as $ namespace => $ path ) { $ templatePaths [ ] = new TemplatePath ( $ namespace , $ path ) ; } return $ templatePaths ; }
Get the template directories
35,407
protected function renderPayloadDataAsMarkupList ( array $ data , $ indent = 0 ) { $ markup = '' ; foreach ( $ data as $ key => $ value ) { $ markup .= str_repeat ( ' ' , $ indent * 2 ) . '- ' . $ key . ':' ; if ( TRUE === is_array ( $ value ) ) { $ markup .= $ this -> renderPayloadDataAsMarkupList ( $ value , ++ $ indent ) ; } else { $ markup .= ' ' . $ value . PHP_EOL ; } } return TRUE === empty ( $ markup ) ? '' : PHP_EOL . $ markup ; }
Renders a deep array as a nested list of unordered menu items in Markdown format .
35,408
public function getLimit ( $ sql , $ page , $ num = 0 , $ params = array ( ) , $ next_page = false ) { $ num = ( int ) $ num ; $ sql .= ' limit :limit_from,:limit' ; if ( $ next_page && $ num ) { $ limit_from = ( $ page - 1 ) * ( $ num - 1 ) ; } else { $ limit_from = ( $ page - 1 ) * $ num ; } $ ret = $ this -> getAll ( $ sql , array_merge ( $ params , array ( 'limit' => $ num , 'limit_from' => $ limit_from ) ) ) ; return $ ret ; }
Get limit reulst
35,409
public function getPager ( $ sql , $ page , $ num = 0 , $ params = array ( ) ) { $ ret = $ this -> getLimit ( $ sql , $ page , $ num + 1 , $ params , true ) ; $ count = count ( $ ret ) ; $ count > $ num && array_pop ( $ ret ) ; return array ( 'rs' => $ ret , 'next' => $ count > $ num ? true : false , ) ; }
Get result and next assertions
35,410
public function getAll ( $ sql , $ params = array ( ) ) { $ stmt = $ this -> execute ( $ sql , $ params ) ; return $ stmt -> fetchAll ( $ this -> fetchMode ) ; }
Get all result
35,411
public function getOneAll ( $ sql , $ params = array ( ) , $ column_number = 0 ) { $ stmt = $ this -> execute ( $ sql , $ params ) ; $ all = array ( ) ; while ( $ row = $ stmt -> fetch ( PDO :: FETCH_NUM ) ) { $ all [ ] = $ row [ $ column_number ] ; } return $ all ; }
Get one column together into an array
35,412
public function getOne ( $ sql , $ params = array ( ) , $ column_number = 0 ) { $ stmt = $ this -> execute ( $ sql , $ params ) ; return $ stmt -> fetchColumn ( $ column_number ) ; }
Get one column result
35,413
public function removeCriteria ( $ criteriaName = '' ) { if ( ! empty ( $ criteriaName ) ) { $ this -> stack = $ this -> stack -> filter ( function ( CriteriaInterface $ criteria ) use ( $ criteriaName ) { return ! is_a ( $ criteria , $ criteriaName ) ; } ) ; return true ; } $ this -> stack = new Collection ( ) ; return true ; }
Remove one or all criteria from stack .
35,414
public function executeOn ( Builder $ query ) { $ this -> stack -> each ( function ( CriteriaInterface $ criteria ) use ( $ query ) { $ criteria -> execute ( $ query ) ; } ) ; return $ query ; }
Execute an criterias from the stack on given query builder .
35,415
public function onRequest ( GetResponseEvent $ event ) { if ( ! $ event -> isMasterRequest ( ) ) { return ; } $ request = $ event -> getRequest ( ) ; $ request -> setSession ( $ this -> session ) ; $ this -> prependBasePathToCookie ( $ request ) ; $ this -> appendRealmToName ( $ request ) ; $ name = $ this -> session -> getName ( ) ; if ( $ request -> cookies -> has ( $ name ) ) { $ this -> session -> setId ( $ request -> cookies -> get ( $ name ) ) ; $ this -> session -> start ( ) ; } }
Set the session ID from request cookies .
35,416
public function onResponse ( FilterResponseEvent $ event ) { if ( ! $ event -> isMasterRequest ( ) || ! $ this -> session -> isStarted ( ) ) { return ; } $ this -> session -> save ( ) ; $ cookie = $ this -> generateCookie ( ) ; $ event -> getResponse ( ) -> headers -> setCookie ( $ cookie ) ; }
Add the session cookie to the response if it is started .
35,417
public function create ( OptionsBag $ sessionOptions ) { $ connections = $ this -> parse ( $ sessionOptions ) ; $ options = $ this -> parseOptions ( $ sessionOptions ) ; return new Predis \ Client ( $ connections , $ options ) ; }
Creates a Predis instance from the session options .
35,418
protected function parseOptions ( OptionsBag $ sessionOptions ) { $ options = $ sessionOptions -> get ( 'options' , [ ] ) ; if ( $ sessionOptions -> get ( 'prefix' ) ) { Deprecated :: warn ( 'Specifying "prefix" directly in session config' , 1.0 , 'Move it under the "options" key.' ) ; $ options [ 'prefix' ] = $ sessionOptions -> get ( 'prefix' ) ; } return $ options ; }
Parse Predis options from session options .
35,419
private function assertValidAlgorithmConfiguration ( array $ algorithmConfig ) { if ( ! array_key_exists ( 'id' , $ algorithmConfig ) || ! $ this -> containsValidCryptoConfig ( $ algorithmConfig , 'decryption' ) || ! $ this -> containsValidCryptoConfig ( $ algorithmConfig , 'encryption' ) ) { throw new InvalidAlgorithmConfigurationException ( ) ; } }
Assert that algorithm configuration is valid .
35,420
private function containsValidCryptoConfig ( $ algorithmConfig , $ type ) { return ( array_key_exists ( $ type , $ algorithmConfig ) && \ is_array ( $ algorithmConfig [ $ type ] ) && array_key_exists ( 'key' , $ algorithmConfig [ $ type ] ) && array_key_exists ( 'service' , $ algorithmConfig [ $ type ] ) ) ; }
Check if an algorithm configuration contains a valid crypto configuration .
35,421
protected function interact ( InputInterface $ input , OutputInterface $ output ) { $ console = $ this -> getHelper ( 'question' ) ; $ output -> writeln ( [ '' , 'This command will create a <info>user</info> for <comment>Shuwee admin</comment>' , '' , ] ) ; $ username = null ; try { $ username = $ input -> getArgument ( 'username' ) ? $ this -> usernameValidator ( $ input -> getArgument ( 'username' ) ) : null ; } catch ( \ Exception $ error ) { $ output -> writeln ( $ console -> getHelperSet ( ) -> get ( 'formatter' ) -> formatBlock ( $ error -> getMessage ( ) , 'error' ) ) ; } if ( null === $ username ) { $ question = new Question ( '<info>Username</info>: ' ) ; $ question -> setValidator ( [ $ this , 'usernameValidator' ] ) ; $ question -> setMaxAttempts ( self :: MAX_ATTEMPTS ) ; $ username = $ console -> ask ( $ input , $ output , $ question ) ; $ input -> setArgument ( 'username' , $ username ) ; } else { $ output -> writeln ( '<info>Username</info>: ' . $ username ) ; } $ password = null ; try { $ password = $ input -> getArgument ( 'password' ) ? $ this -> passwordValidator ( $ input -> getArgument ( 'password' ) ) : null ; } catch ( \ Exception $ error ) { $ output -> writeln ( $ console -> getHelperSet ( ) -> get ( 'formatter' ) -> formatBlock ( $ error -> getMessage ( ) , 'error' ) ) ; } if ( null === $ password ) { $ question = new Question ( '<info>Password</info> (your type will be hidden): ' ) ; $ question -> setValidator ( [ $ this , 'passwordValidator' ] ) ; $ question -> setHidden ( true ) ; $ question -> setMaxAttempts ( self :: MAX_ATTEMPTS ) ; $ password = $ console -> ask ( $ input , $ output , $ question ) ; $ input -> setArgument ( 'password' , $ password ) ; } else { $ output -> writeln ( '<info>Password</info>: ' . str_repeat ( '*' , strlen ( $ password ) ) ) ; } $ output -> writeln ( '' ) ; }
Validates input and ask for missing arguments if any
35,422
public function create ( RoutePath $ path , array $ attributes = [ ] ) : string { $ uri = new PathUri ( $ path , $ attributes ) ; return ( string ) $ uri ; }
Creates new path URI .
35,423
private function addRewriterReferenceByPriority ( array $ rewriterReferences , $ taggedServiceId , array $ tag ) { $ priority = ( array_key_exists ( self :: TAG_ATTRIBUTE_PRIORITY , $ tag ) ? ( int ) $ tag [ self :: TAG_ATTRIBUTE_PRIORITY ] : self :: DEFAULT_PRIORITY ) ; if ( ! array_key_exists ( $ priority , $ rewriterReferences ) ) { $ rewriterReferences [ $ priority ] = [ ] ; } $ rewriterReferences [ $ priority ] [ ] = $ this -> referenceFactory -> createReference ( $ taggedServiceId ) ; return $ rewriterReferences ; }
Add rewriter reference by priority .
35,424
private function injectRewritersIntoRegistry ( ContainerBuilder $ container , array $ references ) { $ registryDefinition = $ container -> getDefinition ( ServiceNames :: BUNDLE_CONFIGURATION_SERVICE_DEFINITION_REWRITER_REGISTRY ) ; $ arguments = $ registryDefinition -> getArguments ( ) ; $ arguments [ 0 ] = $ references ; $ registryDefinition -> setArguments ( $ arguments ) ; }
Inject rewriters into registry .
35,425
private function setExtensionConfigurationKeyForRewriter ( ContainerBuilder $ container , $ rewriterServiceId , $ extensionConfigKey ) { $ rewriterDefinition = $ container -> getDefinition ( $ rewriterServiceId ) ; $ methodCalls = $ rewriterDefinition -> getMethodCalls ( ) ; $ methodCalls [ ] = [ 'setExtensionConfigurationKey' , [ $ extensionConfigKey ] ] ; $ rewriterDefinition -> setMethodCalls ( $ methodCalls ) ; }
Set extension configuration key for rewriter .
35,426
public function console ( $ messages , $ options = ConsoleOutput :: VERBOSITY_NORMAL ) { $ time = date ( "Y-m-d H:i:s" ) ; $ wid = 0 ; $ processFlag = isset ( $ this -> swoole -> master_pid ) ? '@' : '#' ; $ pid = getmypid ( ) ; if ( isset ( $ this -> swoole -> worker_id ) && $ this -> swoole -> worker_id >= 0 ) { $ wid = $ this -> swoole -> worker_id ; if ( $ this -> swoole -> taskworker ) { $ processFlag = '^' ; } else { $ processFlag = '*' ; } } if ( isset ( $ this -> swoole -> manager_pid ) && $ this -> swoole -> manager_pid == $ pid ) { $ processFlag = '$' ; } if ( isset ( $ this -> swoole -> master_pid ) && $ this -> swoole -> master_pid == $ pid ) { $ processFlag = '#' ; } $ messages = sprintf ( "[%s %s%d.%d]<info>\tINFO\t</info>%s" , $ time , $ processFlag , $ pid , $ wid , $ messages ) ; $ this -> output -> writeln ( $ messages , $ options ) ; }
Write message to consle with datetime & pid info
35,427
public function onShutdown ( swoole_server $ server ) { if ( file_exists ( $ this -> pidFile ) ) { unlink ( $ this -> pidFile ) ; } $ this -> console ( sprintf ( 'Server <info>%s</info> Master[<info>%s</info>] is shutdown ' , $ this -> name , $ server -> master_pid ) , OutputInterface :: VERBOSITY_DEBUG ) ; }
Shutdown server process .
35,428
public function generateBody ( ) { if ( count ( $ this -> body ) === 0 ) { return '{' . $ this -> getLineFeed ( ) . $ this -> getIndentation ( ) . '}' ; } else { $ code = array ( ) ; $ code [ ] = '{' ; foreach ( $ this -> body as $ line ) { $ line -> addIndentationLevel ( $ this -> getIndentationLevel ( ) + 1 ) ; $ line -> setIndentationString ( $ this -> getIndentationString ( ) ) ; $ code [ ] = rtrim ( $ line -> generate ( ) ) ; } $ code [ ] = $ this -> getIndentation ( ) . '}' ; return implode ( $ this -> getLineFeed ( ) , $ code ) ; } }
Generate the body .
35,429
public function dashboardAction ( ) { $ translator = $ this -> container -> get ( 'translator' ) ; $ adminManager = $ this -> get ( 'shuwee_admin.admin_manager' ) ; $ sections = [ ] ; foreach ( $ adminManager -> getAdmins ( ) as $ alias => $ admin ) { $ section = $ admin -> getOption ( 'menu_section' ) ; if ( ! is_string ( $ section ) ) { throw new \ Exception ( sprintf ( '"menu_section" option must return a string, %s returned.' , gettype ( $ section ) ) ) ; } if ( ! isset ( $ sections [ $ section ] ) ) { $ sections [ $ section ] [ 'label' ] = ucfirst ( $ translator -> trans ( $ section , [ ] , 'ShuweeAdminBundle' ) ) ; $ sections [ $ section ] [ 'admins' ] = [ ] ; } $ sections [ $ section ] [ 'admins' ] [ ] = $ admin ; } return $ this -> render ( 'ShuweeAdminBundle:Admin:dashboard.html.twig' , [ 'sections' => $ sections , ] ) ; }
Admin dashboard .
35,430
protected function renderTemplate ( $ templateName , array $ variables = [ ] ) { $ templatePath = __DIR__ . '/../../../stub/' . $ templateName ; if ( ! file_exists ( $ templatePath ) ) { throw new DbExporterException ( 'Template ' . $ templateName . ' not found' ) ; } $ template = file_get_contents ( $ templatePath ) ; $ search = array_keys ( $ variables ) ; $ replace = array_values ( $ variables ) ; foreach ( $ search as & $ item ) { $ item = '{{' . $ item . '}}' ; } return str_replace ( $ search , $ replace , $ template ) ; }
Get rendered template
35,431
protected function writeToFileFromTemplate ( $ path , $ templateName , OutputInterface $ output = null , array $ variables = [ ] , $ overwrite = false ) { if ( $ overwrite || ( ! file_exists ( $ path ) && ! is_dir ( $ path ) ) ) { $ dir = dirname ( $ path ) ; if ( ! file_exists ( $ dir ) || ! is_dir ( $ dir ) ) { mkdir ( $ dir , 0777 , true ) ; } file_put_contents ( $ path , $ this -> renderTemplate ( $ templateName , $ variables ) ) ; $ output -> writeln ( '<info>File created:</info> ' . $ path ) ; } else { $ output -> writeln ( '<info>File already exists:</info> ' . $ path . ' <comment>(Overwrite disabled)</comment>' ) ; } }
Render template content and write to file
35,432
public function keyOf ( $ value ) { foreach ( $ this -> items as $ key => $ iValue ) { if ( $ value === $ iValue ) { return $ key ; } } return null ; }
Get the key of a value if exists .
35,433
public function containsKey ( $ key ) : bool { return isset ( $ this -> items [ $ key ] ) || array_key_exists ( $ key , $ this -> items ) ; }
Test is the key exists .
35,434
public function first ( callable $ callback = null ) { if ( null === $ callback ) { return reset ( $ this -> items ) ; } return $ this -> filter ( $ callback ) -> first ( ) ; }
Get the first time and reset and rewind .
35,435
public function last ( callable $ callback = null ) { if ( null === $ callback ) { return end ( $ this -> items ) ; } return $ this -> filter ( $ callback ) -> last ( ) ; }
Get the last item .
35,436
public function filter ( callable $ callback ) : self { $ collection = Factory :: create ( ) ; $ index = 0 ; foreach ( $ this -> items as $ key => $ value ) { if ( $ callback ( $ value , $ key , $ index ++ ) ) { $ collection -> set ( $ key , $ value ) ; } } return $ collection ; }
Filter and return a new Collection .
35,437
public function combine ( iterable $ values , bool $ inPlace = false ) : self { if ( count ( $ values ) != count ( $ this -> items ) ) { $ this -> doThrow ( 'Invalid input for ' . ( $ inPlace ? 'replace' : 'combine' ) . ', number of items does not match.' , Factory :: getArrayForItems ( $ values ) ) ; } $ values = Factory :: getArrayForItems ( $ values ) ; return Factory :: create ( array_combine ( $ this -> items , $ values ) ) ; }
Combine and return a new Collection . It takes the keys of the current Collection and assign the values .
35,438
public function combineKeys ( iterable $ keys ) : self { if ( count ( $ keys ) != count ( $ this -> items ) ) { $ this -> doThrow ( 'Invalid input for combineKeys, number of items does not match.' , $ keys ) ; } $ collection = Factory :: create ( ) ; $ this -> rewind ( ) ; foreach ( $ keys as $ key ) { $ collection -> set ( $ key , $ this -> current ( ) ) ; $ this -> next ( ) ; } $ this -> rewind ( ) ; return $ collection ; }
Opposite of Combine It keeps the values of the current Collection and assign new keys .
35,439
public function flip ( ) : self { $ collection = Factory :: create ( ) ; foreach ( $ this -> items as $ key => $ value ) { $ collection -> set ( $ value , $ key ) ; } return $ collection ; }
Flip the keys and the values and return a new Collection .
35,440
public function merge ( iterable $ items , bool $ inPlace = false ) : self { $ collection = $ inPlace ? $ this : clone $ this ; foreach ( $ items as $ key => $ value ) { $ collection -> set ( $ key , $ value ) ; } return $ collection ; }
Merge the items and the collections and return a new Collection .
35,441
public function zip ( iterable $ items ) : self { $ collection = Factory :: create ( $ items ) ; return $ this -> map ( function ( $ value , $ key , $ index ) use ( $ collection ) { return [ $ value , $ collection -> atIndex ( $ index ) ] ; } ) ; }
Merge the values items by items and return a new Collection .
35,442
public function slice ( int $ offset , ? int $ length = null ) : self { return Factory :: create ( \ array_slice ( $ this -> items , $ offset , $ length , true ) ) ; }
Get a slice of the collection and inject it in a new Collection .
35,443
public function exists ( callable $ callback ) : bool { $ index = 0 ; foreach ( $ this -> items as $ key => $ item ) { if ( true === $ callback ( $ item , $ key , $ index ++ ) ) { return true ; } } return false ; }
Return true if one item return true to the callback .
35,444
private function readNode ( $ path ) { $ finder = new Finder ( $ path ) ; if ( false !== $ finder -> getPropertiesPath ( ) ) { $ uri = str_replace ( $ this -> contentPath , '' , $ path ) ; $ uri = $ uri ? $ uri : '/' ; $ properties = PropertiesParser :: parse ( $ finder ) ; $ node = new Node ( $ properties [ 'name' ] , $ uri ) ; $ index = 0 ; foreach ( SortorderParser :: parse ( $ finder ) as $ subPath ) { $ child = $ this -> readNode ( $ path . DIRECTORY_SEPARATOR . $ subPath ) ; $ node -> addChildAsLast ( $ child ) ; $ child -> setParent ( $ node ) ; if ( $ index ) { $ child -> setPrev ( $ node -> getChildByIndex ( $ index - 1 ) ) ; $ node -> getChildByIndex ( $ index - 1 ) -> setNext ( $ child ) ; } $ index ++ ; } foreach ( $ properties [ 'properties' ] as $ key => $ value ) { $ node -> setProperty ( $ key , $ value ) ; } return $ node ; } throw new \ Coral \ SiteBundle \ Exception \ SitemapException ( "Unable to find properties for: [$path]" ) ; }
Recursively builds a structure of the sitemap from files
35,445
public function getRoot ( ) { $ cacheKey = 'coral.sitemap.nodes' ; if ( false === ( $ root = $ this -> cache -> fetch ( $ cacheKey ) ) ) { $ root = $ this -> readNode ( $ this -> contentPath ) ; if ( ! $ this -> cache -> save ( $ cacheKey , $ root ) ) { throw new \ Coral \ SiteBundle \ Exception \ SitemapException ( "Unable to store into cache." ) ; } } return $ root ; }
Get Root node
35,446
private function setDate ( $ data , $ key , $ defaultDate , callable $ setCallback ) { $ date = $ this -> getProperty ( $ data , $ key , $ defaultDate ) ; if ( $ date !== null ) { if ( empty ( $ date ) ) { $ date = null ; } if ( is_string ( $ date ) ) { $ date = new \ DateTime ( $ date ) ; } call_user_func ( $ setCallback , $ date ) ; } }
Sets a date if it is set in given data .
35,447
public function assetFiles ( array $ assets , array $ options = [ ] ) : string { $ assets = $ this -> prepareAssets ( $ assets ) ; $ options = array_replace_recursive ( $ this -> options , $ options ) ; $ cacheKey = $ this -> getCacheKey ( $ assets , $ options ) ; $ cacheItem = $ this -> cache -> getItem ( $ cacheKey ) ; if ( $ cacheItem -> isHit ( ) ) { return $ cacheItem -> get ( ) ; } $ jsFiles = [ ] ; $ cssFiles = [ ] ; foreach ( $ assets as $ file ) { $ fileType = strtolower ( pathinfo ( $ file , PATHINFO_EXTENSION ) ) ; if ( $ fileType === 'js' ) { $ jsFiles [ ] = $ file ; } if ( $ fileType === 'css' ) { $ cssFiles [ ] = $ file ; } } $ cssContent = $ this -> css ( $ cssFiles , $ options ) ; $ jsContent = $ this -> js ( $ jsFiles , $ options ) ; $ result = $ cssContent . $ jsContent ; $ cacheItem -> set ( $ result ) ; $ this -> cache -> save ( $ cacheItem ) ; return $ result ; }
Render and compress JavaScript assets .
35,448
protected function getJsContent ( string $ file , bool $ minify ) : string { $ content = file_get_contents ( $ file ) ; if ( $ content === false ) { throw new RuntimeException ( sprintf ( 'File could be read: %s' , $ file ) ) ; } if ( $ minify ) { $ content = JSMin :: minify ( $ content ) ; } return $ content ; }
Minimise JS .
35,449
public function css ( array $ assets , array $ options ) : string { $ contents = [ ] ; $ public = '' ; foreach ( $ assets as $ asset ) { if ( $ this -> isExternalUrl ( $ asset ) ) { $ contents [ ] = sprintf ( '<link rel="stylesheet" type="text/css" href="%s" media="all" />' , $ asset ) ; continue ; } $ content = $ this -> getCssContent ( $ asset , $ options [ 'minify' ] ) ; if ( ! empty ( $ options [ 'inline' ] ) ) { $ contents [ ] = sprintf ( '<style>%s</style>' , $ content ) ; } else { $ public .= $ content . '' ; } } if ( strlen ( $ public ) > 0 ) { $ name = $ options [ 'name' ] ?? 'file.css' ; if ( empty ( pathinfo ( $ name , PATHINFO_EXTENSION ) ) ) { $ name .= '.css' ; } $ url = $ this -> publicCache -> createCacheBustedUrl ( $ name , $ public ) ; $ contents [ ] = sprintf ( '<link rel="stylesheet" type="text/css" href="%s" media="all" />' , $ url ) ; } return implode ( "\n" , $ contents ) ; }
Render and compress CSS assets .
35,450
public function getCssContent ( string $ fileName , bool $ minify ) : string { $ content = file_get_contents ( $ fileName ) ; if ( $ content === false ) { throw new RuntimeException ( sprintf ( 'File could be read: %s' , $ fileName ) ) ; } if ( $ minify === true ) { $ compressor = new CssMinifier ( ) ; $ content = $ compressor -> run ( $ content ) ; } return $ content ; }
Minimize CSS .
35,451
protected function isExternalUrl ( string $ url ) : bool { return ( ! filter_var ( $ url , FILTER_VALIDATE_URL ) === false ) && ( strpos ( $ url , 'vfs://' ) === false ) ; }
Check if url is valid .
35,452
public function onPreSetData ( FormEvent $ event ) { $ form = $ event -> getForm ( ) ; if ( $ this -> authorizationChecker -> isGranted ( 'ROLE_SUPER_ADMIN' ) ) { $ roles = [ 'User' => 'ROLE_USER' , 'Admin' => 'ROLE_ADMIN' , 'Super admin' => 'ROLE_SUPER_ADMIN' , ] ; $ form -> add ( 'roles' , ChoiceType :: class , [ 'label' => 'Roles' , 'required' => true , 'expanded' => true , 'multiple' => true , 'choices' => $ roles , ] ) ; } }
Set appropriate field elements in form
35,453
static public function initialize ( ) { self :: $ cli = PHP_SAPI === 'cli' ; self :: $ path = str_replace ( DIRECTORY_SEPARATOR , '/' , __DIR__ ) ; self :: $ root = str_replace ( DIRECTORY_SEPARATOR , '/' , RAILS_ROOT ) ; self :: $ publicPath = defined ( 'RAILS_PUBLIC_PATH' ) ? RAILS_PUBLIC_PATH : self :: $ root . '/public' ; self :: $ publicPath = str_replace ( DIRECTORY_SEPARATOR , '/' , self :: $ publicPath ) ; self :: $ env = RAILS_ENV ; self :: $ config = self :: defaultConfig ( ) ; include self :: $ path . '/Toolbox/functions.php' ; self :: setRailsConfig ( ) ; }
Boots system .
35,454
private function addAction ( $ actionName ) { $ template = $ this -> templates [ $ actionName ] ; $ command = preg_filter ( '/^/' , ' ' , explode ( PHP_EOL , strtr ( $ template , [ '$actionName' => $ actionName ] ) ) ) ; $ command = array_filter ( $ command , function ( $ var ) { return strlen ( trim ( $ var ) ) ; } ) ; $ command = implode ( PHP_EOL , $ command ) ; $ this -> commands [ ] = $ command ; }
Parses and adds a controller action
35,455
public function refresh ( $ caller , array $ parameters = [ ] ) { $ cacheKey = $ this -> cacheKey ( $ caller , $ parameters ) ; $ this -> cache ( ) -> forget ( $ cacheKey ) ; return $ this -> store ( $ caller , $ parameters ) ; }
Forget and store new data into cache .
35,456
public function cacheKey ( $ caller , array $ parameters = [ ] ) { $ parameters = compact ( 'caller' , 'parameters' ) ; if ( $ this -> repository -> model instanceof Eloquent || $ this -> repository -> model instanceof Builder ) { $ parameters [ 'eager' ] = md5 ( serialize ( $ this -> repository -> with ) ) ; } if ( $ this -> repository -> mediator -> criteria ( ) -> hasCriteria ( ) ) { $ parameters [ 'criteria' ] = md5 ( serialize ( $ this -> repository -> mediator -> criteria ( ) -> getCriterias ( ) ) ) ; } return md5 ( serialize ( $ parameters ) ) ; }
Generate and return cache key for caller with specified parameters .
35,457
protected function cache ( ) { return method_exists ( $ this -> cache , 'tags' ) ? $ this -> cache -> tags ( $ this -> tag ) : $ this -> cache ; }
Initialize cache repository with specified tag for given model .
35,458
public function store ( $ caller , array $ parameters = [ ] ) { $ this -> forget ( 'all' , [ 'columns' => [ '*' ] ] ) ; $ cacheKey = $ this -> cacheKey ( $ caller , $ parameters ) ; return $ this -> cache ( ) -> remember ( $ cacheKey , $ this -> lifetime , function ( ) use ( $ caller , $ parameters ) { return call_user_func_array ( [ $ this -> repository -> mediator , 'database' ] , [ $ caller , $ parameters ] ) ; } ) ; }
Store data in cache behind caller with specified parameters .
35,459
public function forget ( $ caller , array $ parameters = [ ] ) { $ cacheKey = $ this -> cacheKey ( $ caller , $ parameters ) ; if ( $ caller == 'delete' ) { $ this -> repository -> mediator -> database ( $ caller , $ parameters ) ; } return $ this -> cache ( ) -> forget ( $ cacheKey ) ; }
Forget data in cache behind caller with specified parameters .
35,460
public function retrieveOrStore ( $ caller , array $ parameters = [ ] ) { $ cacheKey = $ this -> cacheKey ( $ caller , $ parameters ) ; return $ this -> retrieve ( $ cacheKey ) ? : $ this -> store ( $ caller , $ parameters ) ; }
Retrieve or store and return data from cache .
35,461
public function retrieve ( $ cacheKey ) { if ( $ this -> has ( $ cacheKey ) ) { return $ this -> cache ( ) -> get ( $ cacheKey ) ; } return false ; }
Return data for given cache key .
35,462
public function locateBestTemplate ( $ name ) { $ templates = $ this -> getTemplates ( $ name ) ; foreach ( $ templates as $ template ) { if ( false !== $ template = $ this -> loader -> findTemplate ( $ template , false ) ) { return $ template ; } } throw new \ Twig_Error_Loader ( sprintf ( "Template \"%s\" not found. Tried the following:\n%s" , $ name , implode ( "\n" , $ templates ) ) ) ; }
Locate first available template
35,463
public function addConstant ( ClassConstantGenerator $ constant ) { $ name = $ constant -> getName ( ) ; if ( isset ( $ this -> constants [ $ name ] ) === true ) { throw new InvalidArgumentException ( 'Constant name "' . $ name . '" already added.' ) ; } $ this -> constants [ $ name ] = $ constant ; }
Add a constant .
35,464
protected function generateConstantsLines ( ) { $ code = array ( ) ; foreach ( $ this -> constants as $ constant ) { $ constant -> setIndentationString ( $ this -> getIndentationString ( ) ) ; $ constant -> setIndentationLevel ( $ this -> getIndentationLevel ( ) + 1 ) ; $ code [ ] = $ constant -> generate ( ) ; $ code [ ] = null ; } return $ code ; }
Generate the constants lines .
35,465
public function leaveGroup ( $ groupId ) { $ token = $ this -> oauth -> getToken ( ) ; $ parameters = array ( 'oauth_token' => $ token [ 'key' ] , ) ; $ this -> oauth -> setOption ( 'success_code' , 204 ) ; $ base = '/v1/people/~/group-memberships/' . $ groupId ; $ path = $ this -> getOption ( 'api.url' ) . $ base ; $ response = $ this -> oauth -> oauthRequest ( $ path , 'DELETE' , $ parameters ) ; return $ response ; }
Method to leave a group .
35,466
public function getDiscussions ( $ id , $ fields = null , $ start = 0 , $ count = 0 , $ order = null , $ category = 'discussion' , $ modifiedSince = null ) { $ token = $ this -> oauth -> getToken ( ) ; $ parameters = array ( 'oauth_token' => $ token [ 'key' ] , ) ; $ base = '/v1/groups/' . $ id . '/posts' ; $ data [ 'format' ] = 'json' ; if ( $ fields ) { $ base .= ':' . $ fields ; } if ( $ start > 0 ) { $ data [ 'start' ] = $ start ; } if ( $ count > 0 ) { $ data [ 'count' ] = $ count ; } if ( $ order ) { $ data [ 'order' ] = $ order ; } if ( $ category ) { $ data [ 'category' ] = $ category ; } if ( $ modifiedSince ) { $ data [ 'modified-since' ] = $ modifiedSince ; } $ path = $ this -> getOption ( 'api.url' ) . $ base ; $ response = $ this -> oauth -> oauthRequest ( $ path , 'GET' , $ parameters , $ data ) ; return json_decode ( $ response -> body ) ; }
Method to get dicussions for a group .
35,467
private function processLikeUnlike ( $ postId , $ like ) { $ token = $ this -> oauth -> getToken ( ) ; $ parameters = array ( 'oauth_token' => $ token [ 'key' ] , ) ; $ this -> oauth -> setOption ( 'success_code' , 204 ) ; $ base = '/v1/posts/' . $ postId . '/relation-to-viewer/is-liked' ; $ xml = '<is-liked>' . $ this -> booleanToString ( $ like ) . '</is-liked>' ; $ path = $ this -> getOption ( 'api.url' ) . $ base ; $ header [ 'Content-Type' ] = 'text/xml' ; $ response = $ this -> oauth -> oauthRequest ( $ path , 'PUT' , $ parameters , $ xml , $ header ) ; return $ response ; }
Method to like or unlike a post .
35,468
public function flagPost ( $ postId , $ flag ) { $ token = $ this -> oauth -> getToken ( ) ; $ parameters = array ( 'oauth_token' => $ token [ 'key' ] , ) ; $ this -> oauth -> setOption ( 'success_code' , 204 ) ; $ base = '/v1/posts/' . $ postId . '/category/code' ; $ xml = '<code>' . $ flag . '</code>' ; $ path = $ this -> getOption ( 'api.url' ) . $ base ; $ header [ 'Content-Type' ] = 'text/xml' ; $ response = $ this -> oauth -> oauthRequest ( $ path , 'PUT' , $ parameters , $ xml , $ header ) ; return $ response ; }
Method to flag a post as a Promotion or Job .
35,469
public function addComment ( $ postId , $ comment ) { $ token = $ this -> oauth -> getToken ( ) ; $ parameters = array ( 'oauth_token' => $ token [ 'key' ] , ) ; $ this -> oauth -> setOption ( 'success_code' , 201 ) ; $ base = '/v1/posts/' . $ postId . '/comments' ; $ xml = '<comment><text>' . $ comment . '</text></comment>' ; $ path = $ this -> getOption ( 'api.url' ) . $ base ; $ header [ 'Content-Type' ] = 'text/xml' ; $ response = $ this -> oauth -> oauthRequest ( $ path , 'POST' , $ parameters , $ xml , $ header ) ; $ response = explode ( 'comments/' , $ response -> headers [ 'Location' ] ) ; return $ response [ 1 ] ; }
Method to add a comment to a post
35,470
public function deleteComment ( $ commentId ) { $ token = $ this -> oauth -> getToken ( ) ; $ parameters = array ( 'oauth_token' => $ token [ 'key' ] , ) ; $ this -> oauth -> setOption ( 'success_code' , 204 ) ; $ base = '/v1/comments/' . $ commentId ; $ path = $ this -> getOption ( 'api.url' ) . $ base ; $ response = $ this -> oauth -> oauthRequest ( $ path , 'DELETE' , $ parameters ) ; return $ response ; }
Method to delete a comment if the current user is the creator or flag it as inappropriate otherwise .
35,471
public function scan ( ) { $ files = $ this -> finder -> create ( ) -> in ( $ this -> getBasePath ( ) ) -> name ( 'theme.json' ) ; foreach ( $ files as $ file ) { $ this -> register ( $ file ) ; } }
Scan themes directory .
35,472
public function register ( $ file ) { $ theme = json_decode ( file_get_contents ( $ file ) , true ) ; $ validator = $ this -> getValidationFactory ( ) -> make ( $ theme , [ 'name' => 'required' , 'theme' => 'required' , 'type' => 'required' , 'version' => 'required' , 'description' => 'required' , 'positions' => 'required' , ] ) ; if ( $ validator -> fails ( ) ) { throw new \ Exception ( 'Invalid theme configuration: ' . $ file -> getRealPath ( ) ) ; } $ this -> themes [ $ theme [ 'type' ] . '.' . $ theme [ 'theme' ] ] = new Theme ( $ theme [ 'name' ] , $ theme [ 'theme' ] , $ theme [ 'type' ] , $ theme [ 'version' ] , $ theme [ 'description' ] , ( array ) $ theme [ 'positions' ] , $ theme ) ; }
Register theme . json file .
35,473
public function findOrFail ( $ theme , $ type = 'frontend' ) { if ( in_array ( $ type . '.' . $ theme , array_keys ( $ this -> themes ) ) ) { return $ this -> themes [ $ type . '.' . $ theme ] ; } throw new ThemeNotFoundException ( 'Theme not found!' ) ; }
Find or fail a theme .
35,474
public function isCompatibleVersion ( ) { $ return = false ; while ( $ this -> read ( ) && ! $ return ) { $ return = ( $ this -> nodeType === \ XMLReader :: ELEMENT ) && $ this -> hasAttributes && ( $ this -> getAttribute ( 'version' ) === '1.4.4' ) ; } return $ return ; }
Returns true if the model is of the right version .
35,475
public function isModelTable ( ) { return ( $ this -> nodeType === \ XMLReader :: ELEMENT ) && $ this -> hasAttributes && ( $ this -> getAttribute ( 'struct-name' ) === 'db.mysql.Table' ) && $ this -> name === 'value' ; }
Returns true if the actual node is a model table .
35,476
public function execute ( $ sql , $ executor ) { foreach ( $ this -> _onquery as $ callback ) $ sql = call_user_func ( $ callback , $ sql ) ; try { $ ts = count ( $ this -> _onresult ) ? microtime ( true ) : NULL ; $ result = call_user_func ( $ executor , $ sql ) ; foreach ( $ this -> _onresult as $ callback ) $ result = call_user_func ( $ callback , $ sql , $ result , $ ts ) ; return $ result ; } catch ( \ Exception $ e ) { foreach ( $ this -> _onerror as $ callback ) call_user_func ( $ callback , $ e ) ; throw $ e ; } }
Executes the query through the internal filters and executor
35,477
public function notifyOnException ( \ Exception $ exception , $ metadata = null , $ severity = 'error' ) { if ( $ this -> enabled ) { $ this -> bugsnagClient -> notifyException ( $ exception , $ metadata , $ severity ) ; } }
Deal with Exceptions
35,478
public function notifyOnError ( $ message , Array $ metadata = null , $ severity = null ) { if ( $ this -> enabled ) { $ this -> bugsnagClient -> notifyError ( 'Error' , $ message , $ metadata , $ severity ) ; } }
Deal with errors
35,479
public function executeSql ( ) { $ params = func_get_args ( ) ; $ sql = array_shift ( $ params ) ; if ( ! $ sql ) throw new Exception \ LogicException ( "Can't execute SQL without SQL" ) ; elseif ( is_array ( $ sql ) ) { $ params = $ sql ; $ sql = array_shift ( $ params ) ; } $ this -> _parse_query_multimark ( $ sql , $ params ) ; if ( ! $ stmt = $ this -> pdo -> prepare ( $ sql ) ) { list ( $ code , $ drvrcode , $ msg ) = $ this -> pdo -> errorInfo ( ) ; $ e = new Exception \ QueryException ( sprintf ( "[PDOStatement error] [SQLSTATE %s] (%s) %s" , $ code , $ drvrcode , $ msg ) ) ; throw $ e ; } elseif ( ! $ stmt -> execute ( $ params ) && Rails :: env ( ) == 'development' ) { list ( $ code , $ drvrcode , $ msg ) = $ stmt -> errorInfo ( ) ; $ e = new Exception \ QueryException ( sprintf ( "[PDOStatement error] [SQLSTATE %s] (%s) %s" , $ code , $ drvrcode , $ msg ) ) ; $ e -> setStatement ( $ stmt , $ params ) ; throw $ e ; } $ err = $ stmt -> errorInfo ( ) ; if ( $ err [ 2 ] ) { ActiveRecord :: setLastError ( $ err , $ this -> name ) ; $ e = new Exception \ QueryException ( sprintf ( "[SQLSTATE %s] (%s) %s" , $ err [ 0 ] , ( string ) $ err [ 1 ] , $ err [ 2 ] ) ) ; $ e -> setStatement ( $ stmt , $ params ) ; $ msg = "Error on database query execution\n" ; $ msg .= $ e -> getMessage ( ) ; Rails :: log ( ) -> warning ( $ msg ) ; } return $ stmt ; }
Executes the sql and returns the statement .
35,480
public function query ( ) { $ stmt = call_user_func_array ( [ $ this , 'executeSql' ] , func_get_args ( ) ) ; if ( ActiveRecord :: lastError ( ) ) return false ; return $ stmt -> fetchAll ( ) ; }
Executes the sql and returns the results .
35,481
public static function getInstance ( ) { if ( null === self :: $ _instance ) { self :: $ _instance = new self ( ) ; self :: $ _instance -> provider = Yii :: $ container -> get ( 'motion\i18n\LanguageProviderInterface' ) ; } return self :: $ _instance ; }
Gets the instance via lazy initialization .
35,482
public function getLabel ( $ locale = null ) { $ locale = null === $ locale ? Yii :: $ app -> language : $ locale ; return $ this -> provider -> getLanguageLabel ( $ locale ) ; }
Returns language label .
35,483
public function createOrderPdfDynamically ( ApiOrderInterface $ apiOrder , $ templateHeaderPath = null , $ templateBasePath = null , $ templateMainPath = null , $ templateFooterPath = null ) { $ data = $ this -> getContentForPdf ( $ apiOrder ) ; if ( $ templateHeaderPath === null ) { $ templateHeaderPath = $ this -> templateHeaderPath ; } $ header = $ this -> pdfManager -> renderTemplate ( $ templateHeaderPath , [ ] ) ; if ( $ templateFooterPath === null ) { $ templateFooterPath = $ this -> templateFooterPath ; } $ footer = $ this -> pdfManager -> renderTemplate ( $ templateFooterPath , [ ] ) ; if ( $ templateBasePath === null ) { $ templateBasePath = $ this -> templateConfirmationPath ; } $ data [ 'templateDynamicBasePath' ] = $ templateBasePath ; if ( $ templateMainPath === null ) { $ templateMainPath = $ this -> templateDynamicPath ; } $ pdf = $ this -> pdfManager -> convertToPdf ( $ templateMainPath , $ data , false , [ 'footer-html' => $ footer , 'header-html' => $ header ] ) ; return $ pdf ; }
Function to create a pdf for a given order using given templates .
35,484
protected function getContentForPdf ( ApiOrderInterface $ apiOrder ) { $ order = $ apiOrder -> getEntity ( ) ; $ customerNumber = null ; if ( $ order -> getCustomerAccount ( ) ) { $ customerNumber = $ order -> getCustomerAccount ( ) -> getNumber ( ) ; } else { $ customerNumber = sprintf ( '%05d' , $ order -> getCustomerContact ( ) -> getId ( ) ) ; } $ data = [ 'recipient' => $ order -> getDeliveryAddress ( ) , 'responsibleContact' => $ order -> getResponsibleContact ( ) , 'deliveryAddress' => $ order -> getDeliveryAddress ( ) , 'customerContact' => $ order -> getCustomerContact ( ) , 'billingAddress' => $ order -> getInvoiceAddress ( ) , 'order' => $ order , 'customerNumber' => $ customerNumber , 'orderApiEntity' => $ apiOrder , 'itemApiEntities' => $ apiOrder -> getItems ( ) , 'templateBasePath' => $ this -> templateBasePath , 'templateMacrosPath' => $ this -> templateMacrosPath , 'website_locale' => $ this -> websiteLocale , ] ; return $ data ; }
Function that sets data array for pdf rendering .
35,485
public function processParameters ( array $ parameters , ContainerBuilder $ container ) { foreach ( $ parameters as $ parameterKey => & $ parameterValue ) { if ( \ is_array ( $ parameterValue ) ) { $ parameterValue = $ this -> processParameters ( $ parameterValue , $ container ) ; continue ; } $ resolvedValue = $ this -> environmentPlaceholderResolver -> resolveEnvironmentPlaceholders ( $ parameterValue , $ container ) ; $ replacementValue = $ this -> replacementFetcher -> getReplacedValueForParameter ( $ parameterKey , $ resolvedValue ) ; if ( null !== $ replacementValue ) { $ parameterValue = $ replacementValue ; } } return $ parameters ; }
Process parameter array .
35,486
public function get ( $ key = null , $ default = null ) { if ( is_null ( $ key ) ) { return $ this -> get ; } return Arr :: get ( $ this -> get , $ key , $ default ) ; }
Gets GET data .
35,487
public function post ( $ key = null , $ default = null ) { if ( is_null ( $ key ) ) { return $ this -> post ; } return Arr :: get ( $ this -> post , $ key , $ default ) ; }
Gets POST data
35,488
public function input ( $ key = null , $ default = null ) { $ combined = Arr :: merge ( $ this -> get , $ this -> post ) ; if ( is_null ( $ key ) ) { return $ combined ; } return Arr :: get ( $ combined , $ key , $ default ) ; }
Gets data from both POST and GET . When keys clash the value from POST will be used .
35,489
public function render ( $ action = null , $ layout = null ) { $ this -> viewPath .= DS . 'Pdf' ; $ content = parent :: render ( $ action , false ) ; if ( $ this -> response -> type ( ) == 'text/html' ) { return $ content ; } $ content = $ this -> tcpdf -> Output ( '' , 'S' ) ; $ this -> Blocks -> set ( 'content' , $ content ) ; $ fileName = $ this -> getFileName ( ) ; $ fileName .= '.pdf' ; $ this -> response -> download ( $ fileName ) ; return $ this -> Blocks -> get ( 'content' ) ; }
Renders view for given view file and layout .
35,490
protected function _createSubHeader ( $ subheader = '' , $ width = [ ] , $ level = 0 ) { if ( empty ( $ width ) ) { return ; } $ this -> tcpdf -> SetTextColor ( 0 ) ; $ this -> tcpdf -> SetDrawColor ( 128 , 0 , 0 ) ; $ this -> tcpdf -> SetLineWidth ( 0.3 ) ; if ( $ level > 3 ) { $ level = 3 ; } $ fontSize = 20 * ( 1 - $ level / 4 ) ; $ this -> tcpdf -> SetFont ( '' , 'BI' , $ fontSize ) ; $ height = $ this -> _rowHeight [ 'SubHeader' ] ; $ cells = [ ] ; $ cells [ ] = [ array_sum ( $ width ) , $ height , $ subheader , 0 , 'L' , false , 0 , '' , '' , true , 0 , false , true , $ height , 'M' , true ] ; $ this -> _writeMulticells ( $ cells ) ; }
Write a subheader for table
35,491
protected function _createTableHeader ( $ header = [ ] , $ width = [ ] ) { if ( empty ( $ header ) || empty ( $ width ) ) { return ; } $ this -> tcpdf -> SetFillColor ( 255 , 0 , 0 ) ; $ this -> tcpdf -> SetTextColor ( 255 ) ; $ this -> tcpdf -> SetDrawColor ( 128 , 0 , 0 ) ; $ this -> tcpdf -> SetLineWidth ( 0.3 ) ; $ this -> tcpdf -> SetFont ( '' , 'B' , 10 ) ; $ height = $ this -> _rowHeight [ 'TableHeader' ] ; $ cells = [ ] ; $ numHeaders = count ( $ header ) ; for ( $ i = 0 ; $ i < $ numHeaders ; ++ $ i ) { $ widthColumn = ( isset ( $ width [ $ i ] ) ? $ width [ $ i ] : 0 ) ; $ headerColumn = ( isset ( $ header [ $ i ] ) ? $ header [ $ i ] : '' ) ; $ cells [ ] = [ $ widthColumn , $ height , $ headerColumn , 'LTRB' , 'C' , true , 0 , '' , '' , true , 0 , false , true , $ height , 'M' , true ] ; } $ this -> _writeMulticells ( $ cells ) ; }
Write a header for table cells
35,492
public function table ( $ data = [ ] , $ width = [ ] , $ align = [ ] , $ header = [ ] , $ level = 0 , $ prevHeader = '' , $ prevLevel = 0 ) { if ( empty ( $ data ) ) { $ subHeader = __d ( 'view_extension' , 'No data to display' ) ; $ this -> _createSubHeader ( $ subHeader , $ width , 0 ) ; $ this -> tcpdf -> Bookmark ( $ subHeader , 0 , 0 , '' , 'B' , [ 0 , 0 , 0 ] ) ; return ; } if ( empty ( $ header ) || empty ( $ width ) ) { return ; } if ( empty ( $ align ) ) { $ align = [ ] ; } foreach ( $ data as $ subHeader => $ rows ) { if ( ! isAssoc ( $ rows ) ) { if ( $ this -> _getFlagUseNonBreakingCells ( ) ) { $ this -> tcpdf -> setAutoPageBreak ( false ) ; $ this -> tcpdf -> startTransaction ( ) ; } if ( ! empty ( $ prevHeader ) ) { $ this -> _createSubHeader ( $ prevHeader , $ width , $ prevLevel ) ; $ this -> tcpdf -> Bookmark ( strip_tags ( $ prevHeader ) , $ prevLevel , 0 , '' , 'B' , [ 0 , 64 , 128 ] ) ; } if ( ! empty ( $ subHeader ) ) { $ this -> _createSubHeader ( $ subHeader , $ width , $ level ) ; $ this -> tcpdf -> Bookmark ( strip_tags ( $ subHeader ) , $ level , 0 , '' , 'B' , [ 0 , 64 , 128 ] ) ; } $ this -> _createTableHeader ( $ header , $ width ) ; $ this -> _createTableRows ( $ rows , $ width , $ align , $ header , $ subHeader , $ level , $ prevHeader , $ prevLevel ) ; if ( ! empty ( $ prevHeader ) ) { $ prevHeader = '' ; } } else { $ subLevel = $ level + 1 ; $ this -> table ( $ rows , $ width , $ align , $ header , $ subLevel , $ subHeader , $ level ) ; } $ y = $ this -> tcpdf -> GetY ( ) ; $ y += ( 12 / ( $ level + 1 ) ) ; $ this -> tcpdf -> SetY ( $ y ) ; } }
Write a table
35,493
private function validateRedirections ( ) { foreach ( $ this -> redirections as $ redirection ) { if ( ! ( array_key_exists ( 'source' , $ redirection ) && array_key_exists ( 'target' , $ redirection ) && array_key_exists ( 'type' , $ redirection ) ) ) { throw new ConfigurationException ( "Invalid redirection line: " . implode ( ',' , $ redirection ) . "." ) ; } } }
Validate redirections configuration
35,494
public function getRedirect ( $ source ) { foreach ( $ this -> redirections as $ redirection ) { if ( false !== ( $ wildcardPos = strpos ( $ redirection [ 'source' ] , '*' ) ) ) { if ( substr ( $ source , 0 , $ wildcardPos ) == substr ( $ redirection [ 'source' ] , 0 , $ wildcardPos ) ) { return array ( rtrim ( $ redirection [ 'target' ] , '*' ) . substr ( $ source , $ wildcardPos ) , $ redirection [ 'type' ] ) ; } } else { if ( $ source == $ redirection [ 'source' ] ) { return array ( $ redirection [ 'target' ] , $ redirection [ 'type' ] ) ; } } } return null ; }
Returns redirection for source
35,495
private function _resultSet ( ) { if ( ! isset ( $ this -> _resultSet ) ) { foreach ( $ this -> _before as $ callback ) { $ callback ( $ this -> _query ) ; } $ this -> _resultSet = $ this -> _query -> execute ( ) ; } return $ this -> _resultSet ; }
Returns the query result set iterator executing the query if needed
35,496
private function _iterator ( ) { if ( ! isset ( $ this -> _iterator ) ) $ this -> _iterator = $ this -> _resultSet ( ) -> getIterator ( ) ; return $ this -> _iterator ; }
Returns the delegate iterator from the resultset
35,497
private function _hydrate ( $ row ) { $ callback = $ this -> _hydrator ; return isset ( $ this -> _hydrator ) ? call_user_func ( $ callback , $ row ) : $ row ; }
Hydrates a row into an object
35,498
protected function getSkeletonDirs ( BundleInterface $ bundle = null ) { $ skeletonDirs = array ( ) ; if ( isset ( $ bundle ) && is_dir ( $ dir = $ bundle -> getPath ( ) . '/Resources/SymfonyIdAdminBundle/skeleton' ) ) { $ skeletonDirs [ ] = $ dir ; } $ kernel = $ this -> getContainer ( ) -> get ( 'kernel' ) ; if ( is_dir ( $ dir = $ kernel -> getRootDir ( ) . '/Resources/SymfonyIdAdminBundle/skeleton' ) ) { $ skeletonDirs [ ] = $ dir ; } $ reflClass = new \ ReflectionObject ( $ this ) ; $ skeletonDirs [ ] = dirname ( $ reflClass -> getFileName ( ) ) . '/../Resources/skeleton' ; $ skeletonDirs [ ] = dirname ( $ reflClass -> getFileName ( ) ) . '/../Resources' ; return $ skeletonDirs ; }
Lookup in priority .
35,499
public function reload ( $ collection = null ) { if ( $ collection === null ) { $ collection = $ this -> getCore ( ) ; } return $ this -> collections ( ) -> reload ( $ collection ) ; }
Helper method to reload a collection