idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
43,300
protected function createFileDriver ( ) { $ path = $ this -> config [ 'files' ] ; $ fileSystem = Helper :: getFileSystem ( ) ; if ( ! $ fileSystem -> isDirectory ( $ path ) ) { throw new SessionException ( "session path({$path}) is not exists." ) ; } return new FileSessionHandler ( $ fileSystem , $ path ) ; }
create file session driver throw SessionException when session save path is not exists
43,301
protected function createMemcacheDriver ( ) { $ serverArray = $ this -> config [ 'servers' ] ; $ persistent = boolval ( $ this -> config [ 'persistent' ] ) ; $ name = trim ( $ this -> config [ 'server_name' ] ) ; $ prefix = trim ( $ this -> config [ 'prefix' ] ) ; $ expireTime = intval ( $ this -> config [ 'lifetime' ] ) ; if ( $ persistent && ( strlen ( $ name ) > 0 ) ) { $ memcached = new Memcached ( $ name ) ; } else { $ memcached = new Memcached ( ) ; } if ( ! sizeof ( $ memcached -> getServerList ( ) ) ) { $ memcached -> addServers ( $ serverArray ) ; } $ store = new MemcachedStore ( $ memcached , $ prefix ) ; return new CacheSessionHandler ( $ store , $ expireTime ) ; }
create memcached session driver throw SessionException when session save path is not exists
43,302
protected function createRedisDriver ( ) { $ serverArray = $ this -> config [ 'servers' ] ; $ persistent = boolval ( $ this -> config [ 'persistent' ] ) ; $ prefix = trim ( $ this -> config [ 'prefix' ] ) ; $ expireTime = intval ( $ this -> config [ 'lifetime' ] ) ; if ( $ persistent ) { foreach ( $ serverArray as $ k => $ v ) { $ v [ 'persistent' ] = true ; $ serverArray [ $ k ] = $ v ; } } $ redisServer = new RedisServer ( $ serverArray ) ; $ redisStore = new RedisStore ( $ redisServer , $ prefix ) ; return new CacheSessionHandler ( $ redisStore , $ expireTime ) ; }
create redis server driver
43,303
public function getDriver ( ) { if ( null != $ this -> driver ) { return $ this -> driver ; } switch ( $ this -> config [ 'driver' ] ) { case "file" : $ this -> driver = $ this -> createFileDriver ( ) ; break ; case "memcached" : $ this -> driver = $ this -> createMemcacheDriver ( ) ; break ; case "redis" : $ this -> driver = $ this -> createRedisDriver ( ) ; break ; default : throw new SessionException ( "Driver [{$this->config['driver']}] not supported." ) ; } return $ this -> driver ; }
get session driver
43,304
public function init ( ) { session_set_save_handler ( $ this -> getDriver ( ) , false ) ; $ this -> setOptions ( $ this -> config -> all ( ) ) ; session_start ( ) ; }
init session handler
43,305
public function logIn ( $ username , $ password ) { session_regenerate_id ( true ) ; $ sql = "SELECT id,password FROM {$this->primaryTable} WHERE username=:username AND inactive=0" ; if ( $ result = $ this -> executeQuery ( $ sql , array ( ":username" => $ username ) ) ) { if ( password_verify ( $ password , $ result [ 0 ] [ 'password' ] ) ) { $ this -> setSessionUserId ( $ result [ 0 ] [ 'id' ] ) ; return true ; } } return false ; }
Log in a User
43,306
protected function buildProfile ( ) { $ sql = "SELECT * FROM {$this->primaryTable} WHERE id=:id" ; if ( $ user = $ this -> executeQuery ( $ sql , array ( ":id" => $ this -> getSessionUserId ( ) ) ) [ 0 ] ) { unset ( $ user [ 'password' ] ) ; foreach ( $ user as $ field => $ value ) { $ this -> profile [ $ field ] = $ value ; } } }
Builds the User s profile data which is exposed to the application
43,307
function getProfileValue ( $ field ) { $ temp = $ this -> getProfile ( ) ; if ( array_key_exists ( $ field , $ temp ) ) { return $ temp [ $ field ] ; } return null ; }
Retrieves a particular profile value from the User s profile
43,308
public function add ( $ key , $ message ) { if ( ! isset ( $ this -> errors [ $ key ] ) ) $ this -> errors [ $ key ] = [ ] ; $ this -> errors [ $ key ] [ ] = $ message ; }
add error message
43,309
public function getAllMessage ( ) { $ messages = [ ] ; foreach ( array_keys ( $ this -> errors ) as $ key ) { $ messages [ $ key ] = $ this -> getMessage ( $ key ) ; } return $ messages ; }
get all each key
43,310
public function getAllMessages ( ) { $ messages = [ ] ; foreach ( array_keys ( $ this -> errors ) as $ key ) { $ messages = array_merge ( $ messages , $ this -> getMessages ( $ key ) ) ; } return $ messages ; }
get all messages
43,311
public function isUriAvailable ( $ uri , $ params = array ( ) ) { $ params = ( object ) $ params ; if ( empty ( $ params -> subdomainId ) ) { return false ; } return ! $ this -> getMapper ( ) -> isSubdomainUriExists ( $ params -> subdomainId , $ uri , empty ( $ params -> id ) ? null : $ params -> id ) ; }
Return true if uri is available in a subdomain
43,312
public static function fromName ( string $ name , ? Throwable $ previous = null ) : DuplicateHelperException { $ message = sprintf ( 'Duplicate helper: %s' , $ name ) ; return new static ( $ message , $ name , $ previous ) ; }
Creates exception for a given helper name
43,313
static function fromKey ( string $ key ) { return self :: $ instanceCache [ static :: class ] [ $ key ] ?? ( self :: $ instanceCache [ static :: class ] [ $ key ] = new static ( $ key , static :: getValue ( $ key ) ) ) ; }
Get instance for the given key
43,314
static function fromValue ( $ value ) { $ key = self :: getKey ( $ value ) ; return self :: $ instanceCache [ static :: class ] [ $ key ] ?? ( self :: $ instanceCache [ static :: class ] [ $ key ] = new static ( $ key , static :: getValue ( $ key ) ) ) ; }
Get instance for the given value
43,315
static function all ( ) : array { $ instances = [ ] ; foreach ( static :: getMap ( ) as $ key => $ value ) { $ instances [ $ key ] = self :: $ instanceCache [ static :: class ] [ $ key ] ?? ( self :: $ instanceCache [ static :: class ] [ $ key ] = new static ( $ key , $ value ) ) ; } return $ instances ; }
Get instance for each defined key - value pair
43,316
public function numeroFormatoBrParaSql ( $ numero ) { $ numero = trim ( $ numero ) ; $ numero = str_replace ( "." , "" , $ numero ) ; $ numero = str_replace ( "," , "." , $ numero ) ; if ( ! is_numeric ( $ numero ) ) { return false ; } return $ numero ; }
Converter um numero de um formato 12 . 345 . 678 00 para um formato 12345678 . 00 .
43,317
public function numeroFormatoSqlParaBr ( $ numero ) { $ numero = trim ( $ numero ) ; $ numero = str_replace ( "," , "" , $ numero ) ; if ( ! is_numeric ( $ numero ) ) { return false ; } if ( strpos ( $ numero , '.' ) === false ) { return number_format ( $ numero , 0 , "," , "." ) ; } return number_format ( $ numero , 2 , "," , "." ) ; }
Converter um numero de um formato 12345678 . 00 para um formato 12 . 345 . 678 00 com ou sem casas decimais .
43,318
public function numeroFormatoSqlParaMoedaBr ( $ numero ) { $ numero = trim ( $ numero ) ; $ numero = str_replace ( "," , "" , $ numero ) ; if ( ! is_numeric ( $ numero ) ) { return false ; } return number_format ( $ numero , 2 , "," , "." ) ; }
Converter um numero de um formato 12345678 para um formato 12 . 345 . 678 00 sempre com casas decimais .
43,319
public function numeroFormatoBrParaMoedaBr ( $ numero ) { $ numero = trim ( $ numero ) ; $ numero = str_replace ( "." , "" , $ numero ) ; $ numero = str_replace ( "," , "." , $ numero ) ; if ( ! is_numeric ( $ numero ) ) { return false ; } return number_format ( $ numero , 2 , "," , "." ) ; }
Converter um numero de um formato 2345678 00 para um formato 12 . 345 . 678 00 sempre com casas decimais .
43,320
public function checarValorArrayMultidimensional ( $ key , $ value , array $ array ) { foreach ( $ array as $ a ) { if ( isset ( $ a [ $ key ] ) && $ a [ $ key ] == $ value ) { return true ; } } return false ; }
Checar se um valor existe em um array multidimensional
43,321
function formatarIeCpfCnpj ( $ valor ) { if ( strlen ( $ valor ) == 9 ) { return $ this -> formatarIe ( $ valor ) ; } if ( strlen ( $ valor ) == 11 ) { return $ this -> formatarCpf ( $ valor ) ; } return $ this -> formatarCnpj ( $ valor ) ; }
Converter um numero para os formatos de Inscricao Estadual Cpf ou Cnpj de acordo com o tamanho do parametro informado .
43,322
function formatarTelefone ( $ valor ) { if ( strlen ( $ valor ) < 10 ) { return $ this -> formatarValor ( $ valor , '####-####' ) ; } if ( strlen ( $ valor ) == 10 ) { return $ this -> formatarValor ( $ valor , '(##) ####-####' ) ; } return $ this -> formatarValor ( $ valor , '(##) #####-####' ) ; }
Converter um numero para os formatos de telefone simples telefone com ddd ou telefone celular de acordo com o tamanho do parametro informado .
43,323
public function indexAction ( Request $ request ) { $ form = $ this -> createForm ( new ExtendableConfigurationType ( $ this -> get ( 'madrak_io_extendable_configuration.extendable_configuration_chain' ) -> getBuiltConfiguration ( ) ) ) ; $ form -> setData ( $ this -> get ( 'madrak_io_extendable_configuration.configuration_service' ) -> getAll ( ) ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) === true ) { $ entityClass = $ this -> getParameter ( 'madrak_io_extendable_configuration.configuration_class' ) ; $ entityManager = $ this -> get ( 'doctrine.orm.default_entity_manager' ) ; $ repository = $ entityManager -> getRepository ( $ entityClass ) ; $ recursiveIteratorIterator = new RecursiveIteratorIterator ( new RecursiveArrayIterator ( $ form -> getData ( ) [ 'configuration' ] ) ) ; foreach ( $ recursiveIteratorIterator as $ configurationValue ) { $ keys = [ ] ; for ( $ depth = 0 ; $ depth <= $ recursiveIteratorIterator -> getDepth ( ) ; ++ $ depth ) { $ keys [ ] = $ recursiveIteratorIterator -> getSubIterator ( $ depth ) -> key ( ) ; } $ configurationField = implode ( '.' , $ keys ) ; $ configurationEntity = $ repository -> findOneBy ( [ 'field' => $ configurationField ] ) ; if ( ( $ configurationEntity instanceof $ entityClass ) === false ) { $ configurationEntity = new $ entityClass ( ) ; $ configurationEntity -> setField ( $ configurationField ) ; } $ configurationEntity -> setValue ( $ configurationValue ) ; $ entityManager -> persist ( $ configurationEntity ) ; } $ entityManager -> flush ( ) ; } return $ this -> render ( 'MadrakIOExtendableConfigurationBundle:Configuration:edit.html.twig' , [ 'parent_template' => $ this -> getParentTemplate ( ) , 'form' => $ form -> createView ( ) , ] ) ; }
Lists all available configurations .
43,324
public static function char ( $ symbol ) { if ( is_string ( $ symbol ) && EmojiDictionary :: get ( $ symbol ) ) $ symbol = EmojiDictionary :: get ( $ symbol ) ; if ( is_array ( $ symbol ) ) { $ output = '' ; foreach ( $ symbol as $ sequence ) $ output .= self :: char ( $ sequence ) ; return $ output ; } return self :: uni2utf8 ( $ symbol ) ; }
Return an emoji as char
43,325
public static function html ( $ symbol ) { if ( is_string ( $ symbol ) && EmojiDictionary :: get ( $ symbol ) ) $ symbol = EmojiDictionary :: get ( $ symbol ) ; if ( is_array ( $ symbol ) ) { $ output = '' ; foreach ( $ symbol as $ sequence ) $ output .= self :: html ( $ sequence ) ; return $ output ; } $ symbol = dechex ( $ symbol ) ; return '&#x' . $ symbol ; }
Return an emoji as a html entity
43,326
public function removeTrainingSlash ( $ url ) { if ( null === $ url || strlen ( $ url ) <= 2 ) { return $ url ; } return ( substr ( $ url , - 1 , 1 ) == '/' ) ? substr ( $ url , 0 , - 1 ) : $ url ; }
Removes a trailing slash from an url string .
43,327
public function buildUrlString ( $ baseUrl , $ resource ) { if ( null === $ baseUrl || '' == $ baseUrl ) { return null ; } if ( null === $ resource || '' == $ resource ) { return $ baseUrl ; } $ baseUrl = $ this -> removeTrainingSlash ( $ baseUrl ) ; if ( ! substr ( $ resource , 0 , 1 ) == '/' ) { $ resource = '/' . $ resource ; } return $ baseUrl . $ resource ; }
Returns either the concatenated string or null on wrong params .
43,328
public function parseNewLineSeparatedBody ( $ body ) { $ data = array ( ) ; if ( ! $ body ) { return $ data ; } $ parts = preg_split ( "/\\r?\\n/" , $ body ) ; foreach ( $ parts as $ str ) { if ( ! $ str ) { continue ; } list ( $ key , $ value ) = explode ( '=' , $ str ) ; $ data [ $ key ] = $ value ; } return $ data ; }
Separates given string in key value parts .
43,329
private function make_output ( $ assets , $ type ) { $ output = '' ; $ output .= '<pre>' . $ type . ' trovati in coda' . "\r\n" ; foreach ( $ assets -> queue as $ asset ) { if ( ! isset ( $ assets -> registered [ $ asset ] ) ) { continue ; } $ output .= "\r\nHandle: <strong>" . $ asset . "</strong>\n" ; $ output .= "<i class='small'>URL: " . $ assets -> registered [ $ asset ] -> src . "</i class='small'>\r\n" ; $ deps = $ assets -> registered [ $ asset ] -> deps ; if ( $ deps ) { $ output .= 'Dipende da >>>>>>> ' ; foreach ( $ deps as $ dep ) { $ output .= '<strong>' . $ dep . '</strong>, ' ; } $ output .= "\r\n" ; } else { $ output .= "Non dipende da nessuno\r\n" ; } } $ output .= "\r\n</pre>" ; return $ output ; }
Make the list assets output .
43,330
public function create ( ExpressionInterface $ expression = null ) { if ( $ expression instanceof ConditionInterface ) { return new ConditionBuilder ( $ expression ) ; } elseif ( $ expression instanceof JoinInterface ) { return new JoinBuilder ( $ expression ) ; } else { return new NullBuilder ( ) ; } }
Create and return an instance of a specific expression builder .
43,331
public function persist ( $ identifier , ParameterBagInterface $ parameterBag ) { $ stateFilename = $ this -> getStateFilename ( $ identifier ) ; if ( ! touch ( $ stateFilename ) || ( file_exists ( $ stateFilename ) && ! is_writable ( $ stateFilename ) ) ) { throw new IOException ( "State isn't writable!" ) ; } file_put_contents ( $ stateFilename , serialize ( $ parameterBag ) ) ; }
Puts the parameter bag to a persistent storage .
43,332
public function load ( $ identifier , ParameterBagInterface $ parameterBag ) { $ stateFilename = $ this -> getStateFilename ( $ identifier ) ; if ( ! file_exists ( $ stateFilename ) ) { throw new IOException ( "State file {$stateFilename} doesn't exist!" ) ; } $ stateFileContent = file_get_contents ( $ stateFilename ) ; $ parameterBag -> add ( unserialize ( $ stateFileContent ) ) ; }
Loads the parameter bag from a persistent storage .
43,333
protected function parse ( $ url ) { $ html = $ this -> get ( $ url ) -> getBody ( ) -> getContents ( ) ; $ parser = $ this -> getParser ( $ html ) ; return $ parser ; }
Parse HTML page
43,334
public function into ( $ table = null ) : Insert { $ this -> into = [ ] ; if ( ! \ is_string ( $ table ) && ! \ is_array ( $ table ) ) { throw new InvalidArgumentException ( '$table has to be an array or a string' ) ; } $ this -> into = $ this -> namesClass -> parse ( $ table , true ) ; return $ this ; }
Adds table names for insert
43,335
public function getCollection ( ) { $ collectionName = $ this -> collectionName ; if ( empty ( $ collectionName ) ) { return NULL ; } $ collection = $ collectionName :: getInstance ( ) ; return $ collection ; }
Get collection of such elements
43,336
protected function getfieldsvalues ( & $ qr_fields , & $ qr_values ) { $ qr_fields = array ( ) ; $ qr_values = array ( ) ; parent :: getfieldsvalues ( $ qr_fields , $ qr_values ) ; if ( empty ( $ this -> { $ this -> parentKeyName } ) ) { $ qr_fields [ ] = '`' . $ this -> parentKeyName . '`' ; $ qr_values [ ] = 'NULL' ; } else { $ qr_fields [ ] = '`' . $ this -> parentKeyName . '`' ; $ qr_values [ ] = $ this -> { $ this -> parentKeyName } ; } $ qr_fields [ ] = '`' . $ this -> leftKeyName . '`' ; $ qr_values [ ] = $ this -> { $ this -> leftKeyName } ; $ qr_fields [ ] = '`' . $ this -> rightKeyName . '`' ; $ qr_values [ ] = $ this -> { $ this -> rightKeyName } ; $ qr_fields [ ] = '`' . $ this -> levelKeyName . '`' ; $ qr_values [ ] = $ this -> { $ this -> levelKeyName } ; $ qr_fields [ ] = '`' . $ this -> groupKeyName . '`' ; $ qr_values [ ] = $ this -> { $ this -> groupKeyName } ; return true ; }
Get values of fields .
43,337
public function newAction ( Inventory $ inventory ) { $ inventoryitem = new InventoryItem ( ) ; $ inventoryitem -> setInventory ( $ inventory ) ; $ form = $ this -> createForm ( new InventoryItemType ( ) , $ inventoryitem ) ; return array ( 'inventoryitem' => $ inventoryitem , 'form' => $ form -> createView ( ) , ) ; }
Displays a form to create a new InventoryItem entity .
43,338
public function createAction ( Request $ request ) { $ inventoryitem = new InventoryItem ( ) ; $ form = $ this -> createForm ( new InventoryItemType ( ) , $ inventoryitem ) ; if ( $ form -> handleRequest ( $ request ) -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ inventoryitem ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'stock_inventory_show' , array ( 'id' => $ inventoryitem -> getInventory ( ) -> getId ( ) ) ) ) ; } return array ( 'inventoryitem' => $ inventoryitem , 'form' => $ form -> createView ( ) , ) ; }
Creates a new InventoryItem entity .
43,339
public function editAction ( InventoryItem $ inventoryitem ) { $ editForm = $ this -> createForm ( new InventoryItemType ( ) , $ inventoryitem , array ( 'action' => $ this -> generateUrl ( 'stock_inventoryitem_update' , array ( 'id' => $ inventoryitem -> getid ( ) ) ) , 'method' => 'PUT' , ) ) ; $ deleteForm = $ this -> createDeleteForm ( $ inventoryitem -> getId ( ) , 'stock_inventoryitem_delete' ) ; return array ( 'inventoryitem' => $ inventoryitem , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; }
Displays a form to edit an existing InventoryItem entity .
43,340
public function updateAction ( InventoryItem $ inventoryitem , Request $ request ) { $ editForm = $ this -> createForm ( new InventoryItemType ( ) , $ inventoryitem , array ( 'action' => $ this -> generateUrl ( 'stock_inventoryitem_update' , array ( 'id' => $ inventoryitem -> getid ( ) ) ) , 'method' => 'PUT' , ) ) ; if ( $ editForm -> handleRequest ( $ request ) -> isValid ( ) ) { $ this -> getDoctrine ( ) -> getManager ( ) -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'stock_inventoryitem_show' , array ( 'id' => $ inventoryitem -> getId ( ) ) ) ) ; } $ deleteForm = $ this -> createDeleteForm ( $ inventoryitem -> getId ( ) , 'stock_inventoryitem_delete' ) ; return array ( 'inventoryitem' => $ inventoryitem , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; }
Edits an existing InventoryItem entity .
43,341
public function describe ( AbstractCommand $ command ) { $ options = $ command -> getAllOptions ( ) ; $ optionDescriptor = $ this -> getOptionDescriptor ( ) ; foreach ( $ options as $ option ) { $ optionDescriptor -> addItem ( $ option ) ; } $ render [ 'option' ] = count ( $ options ) ? "\n\nOptions:\n\n" . $ optionDescriptor -> render ( ) : '' ; $ commands = $ command -> getChildren ( ) ; $ commandDescriptor = $ this -> getCommandDescriptor ( ) ; foreach ( $ commands as $ cmd ) { $ commandDescriptor -> addItem ( $ cmd ) ; } $ render [ 'command' ] = count ( $ commands ) ? "\nAvailable commands:\n\n" . $ commandDescriptor -> render ( ) : '' ; $ console = $ command -> getApplication ( ) ; if ( ! ( $ console instanceof Console ) ) { throw new \ RuntimeException ( sprintf ( 'Help descriptor need Console object in %s command.' , get_class ( $ command ) ) ) ; } $ consoleName = $ console -> getName ( ) ; $ version = $ console -> getVersion ( ) ; $ commandName = $ command -> getName ( ) ; $ description = $ command -> getDescription ( ) ; $ usage = $ command -> getUsage ( ) ; $ help = $ command -> getHelp ( ) ; $ description = explode ( "\n" , $ description ) ; foreach ( $ description as & $ line ) { $ line = trim ( $ line ) ; } $ description = implode ( "\n" , $ description ) ; $ description = $ description ? $ description . "\n" : '' ; $ template = sprintf ( $ this -> template , $ consoleName , $ version , $ commandName , $ description , $ usage , $ help ) ; return str_replace ( array ( '{OPTIONS}' , '{COMMANDS}' ) , $ render , $ template ) ; }
Describe a command detail .
43,342
public function getItems ( $ offset , $ itemCountPerPage ) { $ cacheKey = $ offset . '-' . $ itemCountPerPage ; if ( isset ( $ this -> preloadCache [ $ cacheKey ] ) ) { return $ this -> preloadCache [ $ cacheKey ] ; } return $ this -> loadItems ( $ offset , $ itemCountPerPage ) ; }
Returns an result set of items for a page
43,343
public function getCardNumber ( ) : ? string { if ( ! $ this -> hasCardNumber ( ) ) { $ this -> setCardNumber ( $ this -> getDefaultCardNumber ( ) ) ; } return $ this -> cardNumber ; }
Get card number
43,344
public function getElementId ( ) { if ( $ this -> elementId === null ) { $ param = WebDriver_Util :: parseLocator ( $ this -> locator ) ; $ commandUri = ( null === $ this -> parent ) ? 'element' : "element/{$this->parent->getElementId()}/element" ; $ command = $ this -> driver -> factoryCommand ( $ commandUri , WebDriver_Command :: METHOD_POST , $ param ) ; try { $ result = $ this -> driver -> curl ( $ command ) ; } catch ( WebDriver_Exception $ e ) { $ parentText = ( null === $ this -> parent ) ? '' : " (parent: {$this->parent->getLocator()})" ; $ e -> setMessage ( "Element not found: {$this->locator}{$parentText} with error: {$e->getMessage()}" ) ; throw $ e ; } if ( ! isset ( $ result [ 'value' ] [ 'ELEMENT' ] ) ) { $ parentText = ( null === $ this -> parent ) ? '' : " (parent: {$this->parent->getLocator()})" ; throw new WebDriver_Exception ( "Element not found: {$this->locator}{$parentText}" ) ; } $ this -> elementId = $ result [ 'value' ] [ 'ELEMENT' ] ; } return $ this -> elementId ; }
Get element Id from webdriver
43,345
public function tagName ( ) { if ( ! $ this -> state [ 'tagName' ] ) { $ result = $ this -> sendCommand ( 'element/:id/name' , WebDriver_Command :: METHOD_GET ) ; $ this -> state [ 'tagName' ] = strtolower ( $ result [ 'value' ] ) ; } return $ this -> state [ 'tagName' ] ; }
Get element tag name
43,346
public function location ( ) { $ result = $ this -> sendCommand ( 'element/:id/location' , WebDriver_Command :: METHOD_GET ) ; $ value = $ result [ 'value' ] ; return [ 'x' => $ value [ 'x' ] , 'y' => $ value [ 'y' ] ] ; }
Get element upper - left corner of the page
43,347
private function chromeWithMajorVersion ( $ userAgent ) { $ start_idx = strpos ( $ userAgent , 'Chrome' ) ; $ end_idx = strpos ( $ userAgent , '.' , $ start_idx ) ; if ( $ end_idx === false ) { return substr ( $ userAgent , $ start_idx ) ; } else { return substr ( $ userAgent , $ start_idx , ( $ end_idx - $ start_idx ) ) ; } }
Returns Google Chrome s Major version number
43,348
public function findOrFail ( $ fullslug ) { if ( ! $ tree = $ this -> find ( $ fullslug ) ) { throw ( new ModelNotFoundException ) -> setModel ( Tree :: class ) ; } return $ tree ; }
Find a Tree Item by Slug or throw an exception .
43,349
protected function resolveValue ( Config $ config , $ key ) { $ value = $ config -> getRequired ( $ key ) ; if ( is_array ( $ value ) ) { throw new KeyException ( sprintf ( 'Referenced configuration key "%s" must not be an array.' , $ key ) ) ; } if ( in_array ( $ key , $ this -> referenceStack ) ) { throw new KeyException ( sprintf ( 'Circular reference detected resolving configuration key "%s"' , $ key ) ) ; } $ this -> referenceStack [ ] = $ key ; preg_match_all ( '/%([^%]+)%/' , $ value , $ matches ) ; if ( ! $ matches ) { return ; } foreach ( $ matches [ 1 ] as $ referenceKey ) { $ replacement = $ this -> resolveValue ( $ config , $ referenceKey ) ; $ value = str_replace ( '%' . $ referenceKey . '%' , $ replacement , $ value ) ; } array_pop ( $ this -> referenceStack ) ; return $ value ; }
Resolve a configuration value by replacing any %tokens% with their substituted values .
43,350
public function connect ( array $ config ) { $ connection = $ this -> createConnection ( $ config ) ; $ this -> validateCredentials ( $ config ) ; $ this -> addHeader ( 'Authorization' , 'Basic ' . base64_encode ( array_get ( $ config , 'identifier' ) . ':' . array_get ( $ config , 'secret' ) ) ) ; return $ connection ; }
Establish an API connection .
43,351
public function sortByNameDesc ( ) { $ this -> sort ( function ( SplFileInfo $ a , SplFileInfo $ b ) { return strcmp ( $ b -> getRealpath ( ) , $ a -> getRealpath ( ) ) ; } ) ; return $ this ; }
Sorts files and directories by name DESC .
43,352
public function sortByAccessedTimeDesc ( ) { $ this -> sort ( function ( SplFileInfo $ a , SplFileInfo $ b ) { return ( $ b -> getATime ( ) - $ a -> getATime ( ) ) ; } ) ; return $ this ; }
Sorts files and directories by the last accessed time desc .
43,353
public function sortByChangedTimeDesc ( ) { $ this -> sort ( function ( SplFileInfo $ a , SplFileInfo $ b ) { return ( $ b -> getCTime ( ) - $ a -> getCTime ( ) ) ; } ) ; return $ this ; }
Sorts files and directories by the last inode changed time Desc .
43,354
public function sortByModifiedTimeDesc ( ) { $ this -> sort ( function ( SplFileInfo $ a , SplFileInfo $ b ) { return ( $ b -> getMTime ( ) - $ a -> getMTime ( ) ) ; } ) ; return $ this ; }
Sorts files and directories by the last modified time Desc .
43,355
public function getNFirst ( $ n ) { $ it = new \ ArrayIterator ( ) ; $ j = 0 ; foreach ( $ this as $ file ) { if ( $ j == $ n ) { break ; } $ j ++ ; $ it -> append ( $ file ) ; } $ finder = new static ( ) ; $ finder -> append ( $ it ) ; return $ finder ; }
Get First N Files or Dirs
43,356
public function getAllLoggers ( ) { foreach ( $ this -> config -> getChannelConfigs ( ) as $ name => $ config ) { $ this -> getLogger ( $ name ) ; } return $ this -> getLoggers ( ) ; }
Get all registered loggers . Instantiate if necessary .
43,357
public function getInvoiceAddress ( ) : ? string { if ( ! $ this -> hasInvoiceAddress ( ) ) { $ this -> setInvoiceAddress ( $ this -> getDefaultInvoiceAddress ( ) ) ; } return $ this -> invoiceAddress ; }
Get invoice address
43,358
public function options ( ) { if ( request ( ) -> has ( 'language' ) ) { $ pages = HCPagesTranslations :: select ( 'record_id as id' , 'title' , 'language_code' ) -> where ( 'language_code' , request ( 'language' ) ) ; if ( request ( ) -> has ( 'type' ) ) { $ pages -> whereHas ( 'record' , function ( $ query ) { $ query -> where ( 'type' , strtoupper ( request ( 'type' ) ) ) ; } ) ; } if ( request ( ) -> has ( 'q' ) ) { $ pages -> where ( 'title' , 'LIKE' , '%' . request ( 'q' ) . '%' ) ; } return $ pages -> get ( ) ; } return [ ] ; }
Get options by request data
43,359
public function indexAction ( ) { header ( "HTTP/1.0 404 Not Found" ) ; $ data [ 'title' ] = '404' ; $ data [ 'error' ] = $ this -> _error ; $ this -> view -> render ( 'error/404' , $ data ) ; }
404 page Action load a 404 page with the error message
43,360
public function getUri ( $ withBaseUrl = false ) { $ prefix = $ withBaseUrl ? $ this -> getBaseUrl ( ) : '' ; $ uri = $ prefix . $ this -> uri ; $ uri = '/' . ltrim ( $ uri , '/' ) ; return $ uri ; }
Get URI without baseurl
43,361
public function getParams ( $ withActionParams = false ) { return $ withActionParams ? array_merge ( $ this -> actionParams , $ this -> params ) : $ this -> params ; }
Get current params
43,362
public function getParam ( string $ key ) { $ isActionParam = in_array ( $ key , [ self :: PARAM_CONTROLLER , self :: PARAM_ACTION ] ) ; $ params = $ isActionParam ? $ this -> actionParams : $ this -> params ; return array_key_exists ( $ key , $ params ) ? $ params [ $ key ] : null ; }
Get param value . Get action param if key = controller or action
43,363
public function getURLQuery ( ) { $ qstr = '?' ; $ params = $ this -> getParametersArray ( ) ; $ paramCount = count ( $ params ) ; $ i = 0 ; foreach ( $ params as $ key => $ value ) { if ( $ value === null ) { continue ; } $ qstr .= $ key . '=' . rawurlencode ( $ value ) ; if ( $ i < $ paramCount - 1 ) { $ qstr .= '&' ; } $ i ++ ; } return $ qstr ; }
Builds a query string from an array and takes care of proper url - encoding
43,364
public static function Gst06 ( $ uta , $ utb , $ tta , $ ttb , array $ rnpb ) { $ x ; $ y ; $ s ; $ era ; $ eors ; $ gst ; IAU :: Bpn2xy ( $ rnpb , $ x , $ y ) ; $ s = IAU :: S06 ( $ tta , $ ttb , $ x , $ y ) ; $ era = IAU :: Era00 ( $ uta , $ utb ) ; $ eors = IAU :: Eors ( $ rnpb , $ s ) ; $ gst = IAU :: Anp ( $ era - $ eors ) ; return $ gst ; }
- - - - - - - - - i a u G s t 0 6 - - - - - - - - -
43,365
public function redirectUser ( $ id , $ setFlash = true , $ indexAction = [ 'index' ] , $ editAction = [ 'edit' ] , $ overrideReturnUrl = false ) { if ( $ setFlash === true ) { Yii :: $ app -> session -> setFlash ( 'success' , AdminModule :: t ( 'app' , 'Object saved' ) ) ; } elseif ( is_string ( $ setFlash ) ) { Yii :: $ app -> session -> setFlash ( 'success' , $ setFlash ) ; } if ( $ overrideReturnUrl === false ) { $ returnUrl = Yii :: $ app -> request -> get ( 'returnUrl' , Yii :: $ app -> request -> getReferrer ( ) === null ? Url :: to ( [ $ indexAction ] ) : Yii :: $ app -> request -> getReferrer ( ) ) ; } else { $ returnUrl = $ overrideReturnUrl ; } switch ( Yii :: $ app -> request -> post ( 'action' , 'save' ) ) { case 'save-and-next' : $ url = $ editAction ; $ url [ 'returnUrl' ] = $ returnUrl ; return $ this -> redirect ( $ url ) ; case 'save-and-back' : return $ this -> redirect ( $ returnUrl ) ; default : $ url = $ editAction ; $ url [ 'returnUrl' ] = $ returnUrl ; $ url [ 'id' ] = $ id ; return $ this -> redirect ( $ url ) ; } }
Redirects user as was specified by his action and returnUrl variable on successful record saving .
43,366
public function convertFromRequest ( SimplifiedRequest $ request ) { return Request :: create ( $ request -> path , $ request -> method , array ( ) , array ( ) , array ( ) , $ this -> mapHeaderKeys ( $ request -> headers ) , $ request -> content ) ; }
Convert from simplified request
43,367
protected function mapHeaderKeys ( array $ headers ) { $ phpHeaders = array ( ) ; foreach ( $ headers as $ key => $ value ) { $ phpHeaders [ 'HTTP_' . str_replace ( '-' , '_' , strtoupper ( $ key ) ) ] = $ value ; } return $ phpHeaders ; }
Map header keys
43,368
public function convertFromResponse ( SimplifiedResponse $ response ) { return Response :: create ( $ response -> content , $ response -> status , $ response -> headers ) ; }
Convert from simplified response
43,369
public function compress ( $ type , $ files , $ file ) { if ( $ this -> isUpdated ( $ files ) ) { $ content = $ this -> getFileContents ( $ files ) ; switch ( $ type ) { case 'css' : $ content = $ this -> minifyCSS ( $ content ) ; break ; case 'js' : $ content = $ this -> minifyJS ( $ content ) ; break ; } $ this -> saveFile ( $ file , $ content ) ; } return str_replace ( $ this -> scriptPath , $ this -> coreUrl , $ file ) ; }
get all contents and process the whole contents
43,370
private function getFileContents ( $ files ) { $ content = '' ; $ basePath = $ this -> basePath ; array_walk ( $ files , function ( & $ value , $ key ) use ( & $ content , $ basePath ) { if ( file_exists ( $ basePath . $ value ) ) $ content .= file_get_contents ( $ basePath . $ value ) ; } ) ; return $ content ; }
get contents of all registered files it is also check whether file is exist or not
43,371
protected function getBaseOptions ( ) { $ options = [ 'base_uri' => property_exists ( $ this , 'baseUri' ) ? $ this -> baseUri : '' , 'timeout' => property_exists ( $ this , 'timeout' ) ? $ this -> timeout : 5.0 , 'connect_timeout' => property_exists ( $ this , 'connect_timeout' ) ? $ this -> connect_timeout : 5.0 , ] ; return $ options ; }
Get base options .
43,372
public function add ( ) { $ form = $ this -> getForm ( ) ; $ this -> set ( compact ( 'form' ) ) ; if ( ! $ form -> wasSubmitted ( ) ) { return ; } try { $ this -> getUpdateService ( ) -> setForm ( $ form ) -> update ( ) ; ; } catch ( InvalidFormDataException $ caught ) { Log :: logger ( ) -> addNotice ( $ caught -> getMessage ( ) , $ form -> getData ( ) ) ; $ this -> addErrorMessage ( $ this -> getInvalidFormDataMessage ( ) ) ; return ; } catch ( \ Exception $ caught ) { Log :: logger ( ) -> addCritical ( $ caught -> getMessage ( ) , $ form -> getData ( ) ) ; $ this -> addErrorMessage ( $ this -> getGeneralErrorMessage ( $ caught ) ) ; return ; } $ this -> addSuccessMessage ( $ this -> getCreateSuccessMessage ( $ this -> getUpdateService ( ) -> getEntity ( ) ) ) ; $ this -> redirectFromCreated ( $ this -> getUpdateService ( ) -> getEntity ( ) ) ; }
Handle the add entity request
43,373
function handleflags ( $ i , $ argv ) { if ( ! isset ( $ argv [ 1 ] ) || ! isset ( self :: $ _options [ $ argv [ $ i ] [ 1 ] ] ) ) { throw new Exception ( 'Command line syntax error: undefined option "' . $ argv [ $ i ] . '"' ) ; } $ v = self :: $ _options [ $ argv [ $ i ] [ 1 ] ] == '-' ; if ( self :: $ _options [ $ argv [ $ i ] [ 1 ] ] [ 'type' ] == self :: OPT_FLAG ) { $ this -> { self :: $ _options [ $ argv [ $ i ] [ 1 ] ] [ 'arg' ] } = 1 ; } elseif ( self :: $ _options [ $ argv [ $ i ] [ 1 ] ] [ 'type' ] == self :: OPT_FFLAG ) { $ this -> { self :: $ _options [ $ argv [ $ i ] [ 1 ] ] [ 'arg' ] } ( $ v ) ; } elseif ( self :: $ _options [ $ argv [ $ i ] [ 1 ] ] [ 'type' ] == self :: OPT_FSTR ) { $ this -> { self :: $ _options [ $ argv [ $ i ] [ 1 ] ] [ 'arg' ] } ( substr ( $ v , 2 ) ) ; } else { throw new Exception ( 'Command line syntax error: missing argument on switch: "' . $ argv [ $ i ] . '"' ) ; } return 0 ; }
Process a flag command line argument .
43,374
private function _argindex ( $ n , $ a ) { $ dashdash = 0 ; if ( ! is_array ( $ a ) || ! count ( $ a ) ) { return - 1 ; } for ( $ i = 1 ; $ i < count ( $ a ) ; $ i ++ ) { if ( $ dashdash || ! ( $ a [ $ i ] [ 0 ] == '-' || $ a [ $ i ] [ 0 ] == '+' || strchr ( $ a [ $ i ] , '=' ) ) ) { if ( $ n == 0 ) { return $ i ; } $ n -- ; } if ( $ _SERVER [ 'argv' ] [ $ i ] == '--' ) { $ dashdash = 1 ; } } return - 1 ; }
Return the index of the N - th non - switch argument . Return - 1 if N is out of range .
43,375
function OptPrint ( ) { $ max = 0 ; foreach ( self :: $ _options as $ label => $ info ) { $ len = strlen ( $ label ) + 1 ; switch ( $ info [ 'type' ] ) { case self :: OPT_FLAG : case self :: OPT_FFLAG : break ; case self :: OPT_INT : case self :: OPT_FINT : $ len += 9 ; break ; case self :: OPT_DBL : case self :: OPT_FDBL : $ len += 6 ; break ; case self :: OPT_STR : case self :: OPT_FSTR : $ len += 8 ; break ; } if ( $ len > $ max ) { $ max = $ len ; } } foreach ( self :: $ _options as $ label => $ info ) { switch ( $ info [ 'type' ] ) { case self :: OPT_FLAG : case self :: OPT_FFLAG : echo " -$label" ; echo str_repeat ( ' ' , $ max - strlen ( $ label ) ) ; echo " $info[message]\n" ; break ; case self :: OPT_INT : case self :: OPT_FINT : echo " $label=<integer>" . str_repeat ( ' ' , $ max - strlen ( $ label ) - 9 ) ; echo " $info[message]\n" ; break ; case self :: OPT_DBL : case self :: OPT_FDBL : echo " $label=<real>" . str_repeat ( ' ' , $ max - strlen ( $ label ) - 6 ) ; echo " $info[message]\n" ; break ; case self :: OPT_STR : case self :: OPT_FSTR : echo " $label=<string>" . str_repeat ( ' ' , $ max - strlen ( $ label ) - 8 ) ; echo " $info[message]\n" ; break ; } } }
Print out command - line options
43,376
private function _handleDOption ( $ z ) { if ( $ a = strstr ( $ z , '=' ) ) { $ z = substr ( $ a , 1 ) ; } $ this -> azDefine [ ] = $ z ; }
This routine is called with the argument to each - D command - line option . Add the macro defined to the azDefine array .
43,377
static function merge ( $ a , $ b , $ cmp , $ offset ) { if ( $ a === 0 ) { $ head = $ b ; } elseif ( $ b === 0 ) { $ head = $ a ; } else { if ( call_user_func ( $ cmp , $ a , $ b ) < 0 ) { $ ptr = $ a ; $ a = $ a -> $ offset ; } else { $ ptr = $ b ; $ b = $ b -> $ offset ; } $ head = $ ptr ; while ( $ a && $ b ) { if ( call_user_func ( $ cmp , $ a , $ b ) < 0 ) { $ ptr -> $ offset = $ a ; $ ptr = $ a ; $ a = $ a -> $ offset ; } else { $ ptr -> $ offset = $ b ; $ ptr = $ b ; $ b = $ b -> $ offset ; } } if ( $ a !== 0 ) { $ ptr -> $ offset = $ a ; } else { $ ptr -> $ offset = $ b ; } } return $ head ; }
Merge in a merge sort for a linked list
43,378
function Reprint ( ) { printf ( "// Reprint of input file \"%s\".\n// Symbols:\n" , $ this -> filename ) ; $ maxlen = 10 ; for ( $ i = 0 ; $ i < $ this -> nsymbol ; $ i ++ ) { $ sp = $ this -> symbols [ $ i ] ; $ len = strlen ( $ sp -> name ) ; if ( $ len > $ maxlen ) { $ maxlen = $ len ; } } $ ncolumns = 76 / ( $ maxlen + 5 ) ; if ( $ ncolumns < 1 ) { $ ncolumns = 1 ; } $ skip = ( $ this -> nsymbol + $ ncolumns - 1 ) / $ ncolumns ; for ( $ i = 0 ; $ i < $ skip ; $ i ++ ) { print "//" ; for ( $ j = $ i ; $ j < $ this -> nsymbol ; $ j += $ skip ) { $ sp = $ this -> symbols [ $ j ] ; printf ( " %3d %-${maxlen}.${maxlen}s" , $ j , $ sp -> name ) ; } print "\n" ; } for ( $ rp = $ this -> rule ; $ rp ; $ rp = $ rp -> next ) { printf ( "%s" , $ rp -> lhs -> name ) ; print " ::=" ; for ( $ i = 0 ; $ i < $ rp -> nrhs ; $ i ++ ) { $ sp = $ rp -> rhs [ $ i ] ; printf ( " %s" , $ sp -> name ) ; if ( $ sp -> type == PHP_ParserGenerator_Symbol :: MULTITERMINAL ) { for ( $ j = 1 ; $ j < $ sp -> nsubsym ; $ j ++ ) { printf ( "|%s" , $ sp -> subsym [ $ j ] -> name ) ; } } } print "." ; if ( $ rp -> precsym ) { printf ( " [%s]" , $ rp -> precsym -> name ) ; } print "\n" ; } }
Duplicate the input file without comments and without actions on rules
43,379
public function passRequestData ( ) { $ this -> getValidator ( ) -> setInputData ( $ this -> getRequest ( ) -> query -> all ( ) ) ; $ this -> getValidator ( ) -> setInputData ( $ this -> getRequest ( ) -> request -> all ( ) ) ; return $ this ; }
Helper method . Passes request data .
43,380
public function getRepository ( $ name = null ) { $ repositoryName = $ this -> resolveRepositoryClassName ( $ name ) ; return new $ repositoryName ( $ this -> getValidator ( ) , $ this -> config ) ; }
Gets repository by name
43,381
public static function getRepositoryClassnameByReference ( $ reference ) { $ parts = explode ( ':' , $ reference ) ; if ( ! is_string ( $ reference ) || count ( $ parts ) !== 3 ) { throw new \ Exception ( "Invalid Repository Class Reference. Repository reference should consist of 3 parts separated by colon, for example v1:Products:MyRepository" ) ; } return $ parts [ 0 ] . '\\' . $ parts [ 1 ] . '\\' . 'Entity\\' . $ parts [ 2 ] ; }
Gets Repository class name by Reference
43,382
private function removeFiles ( $ files ) { $ duration = $ this -> option ( 'duration' ) ; $ timestamp = time ( ) - $ duration ; foreach ( $ files as $ file ) { if ( filemtime ( $ file ) < $ timestamp ) { unlink ( $ file ) ; if ( count ( scandir ( dirname ( $ file ) ) ) == 2 ) { rmdir ( dirname ( $ file ) ) ; } } } }
Used internally in order to cycle through all of the files and remove them .
43,383
private function buildFileList ( $ folder ) { $ files = array ( ) ; $ directory = new DirectoryIterator ( $ folder ) ; foreach ( $ directory as $ file ) { if ( $ file -> isDot ( ) ) { continue ; } if ( $ file -> isDir ( ) ) { $ files = array_merge ( $ files , $ this -> buildFileList ( $ file -> getRealPath ( ) ) ) ; } else { $ files [ ] = $ file -> getRealPath ( ) ; } } return $ files ; }
Used internally in order to build a full list of all of the files to build .
43,384
public function check ( $ name ) { if ( isset ( $ this -> cache [ $ name ] ) ) return true ; return $ this -> cookies -> has ( $ name ) ; }
Check if the cookie exists
43,385
public function init ( ) { $ file = 'config' ; if ( $ this -> multiDomain && $ this -> domain ) { $ file = $ this -> getConfigFile ( ) ; } $ config = $ this -> readConfigurationFile ( $ file ) ; switch ( $ config [ 'environment' ] ) { case 'development' : error_reporting ( E_ALL ) ; $ this -> error = 'ALL' ; break ; case 'production' : error_reporting ( 0 ) ; $ this -> error = 'NONE' ; break ; default : $ head = 'Configuration Error' ; $ message = 'The environment is not defined in configuration.json' ; require $ this -> pathApp . 'errors/general_error.php' ; exit ; } $ this -> urlApp = $ config [ 'url_app' ] ; $ pos = strlen ( $ config [ 'relative_url' ] ) - 1 ; if ( $ config [ 'relative_url' ] [ $ pos ] != '/' ) { $ config [ 'relative_url' ] .= '/' ; } $ this -> relativeUrl = $ config [ 'relative_url' ] ; $ this -> indexPage = $ config [ 'index_page' ] ; $ this -> sessionProfile = "" ; if ( isset ( $ config [ 'session-profile' ] ) ) { $ this -> sessionProfile = $ config [ 'session-profile' ] ; } $ this -> environment = $ config [ 'environment' ] ; $ this -> authentication = $ config [ 'authentication' ] ; $ this -> sessionAutostart = $ config [ 'session_autostart' ] ; $ this -> authorizationFile = $ config [ 'authorization_file' ] ; if ( isset ( $ config [ 'database' ] ) && $ config [ 'database' ] != '' ) { $ this -> databaseConfiguration = $ config [ 'database' ] ; } if ( isset ( $ config [ 'i18n' ] ) ) { $ this -> i18nDefaultLocale = $ config [ 'i18n' ] [ 'default' ] ; if ( isset ( $ config [ 'i18n' ] [ 'locales' ] ) ) { $ locales = str_replace ( " " , "" , $ config [ 'i18n' ] [ 'locales' ] ) ; $ this -> i18nLocales = explode ( "," , $ locales ) ; } } $ this -> librariesDefinition = isset ( $ config [ 'libs' ] ) ? $ config [ 'libs' ] : [ ] ; $ this -> dependenciesFile = $ config [ 'dependency_injection' ] ; $ this -> controllersFile = $ config [ 'controllers' ] ; $ this -> middlewaresDefinition = $ config [ 'middlewares' ] ; $ this -> filtersBeforeDefinition = $ config [ 'filters' ] ; $ this -> filtersAfterDefinition = $ config [ 'filters_after_processing' ] ; if ( isset ( $ config [ 'vars' ] ) ) { $ this -> contextVars = $ config [ 'vars' ] ; } }
Carga la configuracion global de la aplicacion
43,386
private function setBasicConstants ( ) { define ( 'PATHROOT' , $ this -> getPathRoot ( ) ) ; define ( 'PATHFRA' , $ this -> getPathFra ( ) ) ; define ( 'PATHAPP' , $ this -> getPathApp ( ) ) ; if ( PHP_SAPI == 'cli' || ! filter_input ( INPUT_SERVER , 'REQUEST_METHOD' ) ) { define ( 'ENOLA_MODE' , 'CLI' ) ; } else { define ( 'ENOLA_MODE' , 'HTTP' ) ; } }
Establece las constantes basicas del sistema
43,387
public function readConfigurationFile ( $ name , $ cache = TRUE ) { $ config = NULL ; if ( $ this -> cacheConfigFiles && $ cache && $ this -> app -> cache != NULL ) { $ config = $ this -> app -> getAttribute ( 'C_' . $ name ) ; } if ( $ config == NULL ) { $ config = $ this -> readFile ( $ name ) ; if ( $ this -> cacheConfigFiles && $ cache && $ this -> app -> cache != NULL ) { $ this -> app -> setAttribute ( 'C_' . $ name , $ config ) ; } } if ( ! is_array ( $ config ) ) { \ Enola \ Support \ Error :: general_error ( 'Configuration Error' , 'The configuration file ' . $ name . ' is not available or is misspelled' ) ; exit ; } return $ config ; }
Devuelve un array con los valores del archivo de configuracion
43,388
public function compileConfigurationFile ( $ file ) { require_once $ this -> pathFra . 'Support/Spyc.php' ; $ info = new \ SplFileInfo ( $ file ) ; $ path = $ info -> getPath ( ) . '/' ; $ name = $ info -> getBasename ( '.' . $ info -> getExtension ( ) ) ; $ config = $ this -> readFileSpecific ( $ path . $ name . '.' . $ info -> getExtension ( ) , $ info -> getExtension ( ) ) ; file_put_contents ( $ path . $ name . '.php' , '<?php $config = ' . var_export ( $ config , true ) . ';' ) ; }
Compila archivos de configuracion . Es necesario indicar path absoluto
43,389
private function readFile ( $ name , $ folder = null ) { $ realConfig = NULL ; $ folder != null ? : $ folder = $ this -> pathApp . $ this -> configurationFolder ; if ( $ this -> configurationType == 'YAML' ) { $ realConfig = \ Spyc :: YAMLLoad ( $ folder . $ name . '.yml' ) ; } else if ( $ this -> configurationType == 'PHP' ) { include $ folder . $ name . '.php' ; $ realConfig = $ config ; } else { $ realConfig = json_decode ( file_get_contents ( $ folder . $ name . '.json' ) , true ) ; } return $ realConfig ; }
Lee un archivo y lo carga en un array
43,390
public function readFileSpecific ( $ path , $ extension = 'yml' ) { $ realConfig = NULL ; if ( $ extension == 'yml' ) { $ realConfig = \ Spyc :: YAMLLoad ( $ path ) ; } else if ( $ extension == 'php' ) { include $ path ; $ realConfig = $ config ; } else { $ realConfig = json_decode ( file_get_contents ( $ path ) , true ) ; } return $ realConfig ; }
Lee un archivo y lo carga en un array A defirencia de readFile a este no le importa el tipo de configuracion ni la carpeta de este archivo . Toma un path completo y lo carga
43,391
protected function hasAllRequiredData ( array $ modifier ) { if ( array_key_exists ( 'operator' , $ modifier ) && ! in_array ( $ modifier [ 'operator' ] , self :: $ allowedFilterOperators ) ) { throw new ModifierException ( 'The filter operator "' . $ modifier [ 'operator' ] . '" is not allowed. You can only use one of the following: ' . implode ( ', ' , self :: $ allowedFilterOperators ) ) ; } return array_key_exists ( 'property' , $ modifier ) && array_key_exists ( 'value' , $ modifier ) ; }
Has the modifier all required data to be applied?
43,392
public function register ( \ Silex \ Application $ app ) { parent :: register ( $ app ) ; $ app -> extend ( 'security.voters' , function ( $ voters ) { return array_merge ( $ voters , $ this -> voters ) ; } ) ; $ this -> app = $ app ; $ this -> app [ 'securilex' ] = $ this ; }
Register with \ Silex \ Application .
43,393
public function boot ( \ Silex \ Application $ app ) { foreach ( $ this -> firewalls as $ firewall ) { $ firewall -> register ( $ this ) ; } $ i = 0 ; $ firewalls = array ( ) ; foreach ( $ this -> unsecuredPatterns as $ pattern => $ v ) { $ firewalls [ 'unsecured_' . ( $ i ++ ) ] = array ( 'pattern' => $ pattern ) ; } $ finalConfig = array_merge ( $ firewalls , $ this -> firewallConfig ) ; $ app [ 'security.firewalls' ] = $ finalConfig ; parent :: boot ( $ app ) ; }
Boot with Silex Application
43,394
public function getFirewall ( $ path = null ) { if ( ! $ path ) { $ path = $ this -> getCurrentPathRelativeToBase ( ) ; } foreach ( $ this -> firewalls as $ firewall ) { if ( $ firewall -> isPathCovered ( $ path ) ) { return $ firewall ; } } return null ; }
Get the firewall with the specific path .
43,395
public function getLoginCheckPath ( ) { $ login_check = $ this -> app [ 'request' ] -> getBasePath ( ) ; if ( ( $ firewall = $ this -> getFirewall ( $ this -> getCurrentPathRelativeToBase ( ) ) ) ) { $ login_check .= $ firewall -> getLoginCheckPath ( ) ; } return $ login_check ; }
Get login check path .
43,396
public function getLogoutPath ( ) { $ logout = $ this -> app [ 'request' ] -> getBasePath ( ) ; if ( ( $ firewall = $ this -> getFirewall ( $ this -> getCurrentPathRelativeToBase ( ) ) ) ) { $ logout .= $ firewall -> getLogoutPath ( ) ; } return $ logout ; }
Get logout path .
43,397
public function prependFirewallConfig ( $ name , $ config ) { $ this -> firewallConfig = array_merge ( array ( $ name => $ config ) , $ this -> firewallConfig ) ; }
Prepend additional data to firewall configuration .
43,398
public function addAuthorizationVoter ( VoterInterface $ voter ) { if ( ! in_array ( $ voter , $ this -> voters ) ) { $ this -> voters [ ] = $ voter ; } }
Add additional voter to authorization module .
43,399
public function isGranted ( $ attributes , $ object = null , $ catchException = true ) { try { return $ this -> app [ 'security.authorization_checker' ] -> isGranted ( $ attributes , $ object ) ; } catch ( AuthenticationCredentialsNotFoundException $ e ) { if ( $ catchException ) { return false ; } throw $ e ; } }
Check if the attributes are granted against the current authentication token and optionally supplied object .