idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
3,900
public function resolve ( ) { if ( is_scalar ( $ this -> value ) ) { if ( is_string ( $ this -> value ) ) { return ScalarTypes :: SCALAR_STRING ; } elseif ( is_bool ( $ this -> value ) ) { return ScalarTypes :: SCALAR_BOOLEAN ; } elseif ( is_integer ( $ this -> value ) ) { return ScalarTypes :: SCALAR_INTEGER ; } elsei...
Resolve the type name of the inner value .
3,901
protected function initOptions ( ) { $ this -> fetchParent ( ) -> fetchItemVariants ( ) -> fetchCustomRouteName ( ) -> fetchDefaultOptions ( ) -> fetchExtra ( ) -> fetchTitle ( ) -> fetchVisible ( ) -> fetchVisibleIfDisabled ( ) -> fetchAliasRouteNames ( ) -> fetchRequireRouteName ( ) -> fetchCustomUrl ( ) -> fetchAddR...
Initialize the item s option values .
3,902
protected function generateChildren ( ) { if ( ! $ this -> hasOption ( 'children' ) || ! is_array ( $ this -> getOption ( 'children' ) ) ) { return ; } $ this -> insertCopyToChildren ( ) ; if ( 'before' == $ this -> propelInsertAt ) { $ this -> generatePropelChildren ( ) ; } foreach ( $ this -> getOption ( 'children' )...
Generate child items based on the passed options .
3,903
protected function insertCopyToChildren ( ) { if ( $ this -> getOption ( 'copy_to_children' , false ) ) { $ options = $ this -> getOptions ( ) ; $ options [ 'children' ] = array ( ) ; $ options [ 'copy_to_children' ] = false ; $ options [ 'title' ] = $ this -> getOption ( 'copy_to_children_title' , $ this -> getTitle (...
If the item is configured to insert itself as its first child this will be done here .
3,904
public function addChildByData ( $ routeName , $ options , $ position = 'last' ) { if ( isset ( $ options [ 'children' ] [ '.defaults' ] ) ) { $ options [ 'children' ] [ '.defaults' ] = array_merge ( $ this -> defaultOptions , $ options [ 'children' ] [ '.defaults' ] ) ; } else { $ options [ 'children' ] [ '.defaults' ...
Add a child to the menu using item data .
3,905
public function addChild ( MenuItem $ item , $ position = 'last' ) { if ( 'first' == $ position ) { $ this -> children = array_merge ( array ( $ item ) , $ this -> children ) ; } elseif ( is_numeric ( $ position ) ) { array_splice ( $ this -> children , ( int ) $ position , 0 , array ( $ item ) ) ; } else { $ this -> c...
Add a child item to the menu at the given position .
3,906
public function addSiblingByData ( $ routeName , array $ options ) { $ item = $ this -> getMenu ( ) -> createItem ( $ routeName , $ options ) ; return $ this -> getParentItem ( ) -> addChild ( $ item , $ this -> getItemPosition ( ) + 1 ) ; }
Add an item next to this menu item .
3,907
protected function fetchCustomRouteName ( ) { $ this -> fetchOption ( 'customRouteName' ) ; if ( null !== $ this -> customRouteName ) { $ this -> routeName = $ this -> customRouteName ; } return $ this ; }
Fetch the item s custom_route_name option .
3,908
protected function addAliasRoutes ( $ aliasRoutes ) { $ aliasRoutes = ( array ) $ aliasRoutes ; foreach ( $ aliasRoutes as $ aliasRoute ) { $ aliasRoute = ( string ) $ aliasRoute ; $ this -> aliasRouteNames [ $ aliasRoute ] = $ aliasRoute ; } return $ this ; }
Add 1 or more alias routes passing either a route name or an array of route names .
3,909
public function getExtra ( $ name , $ default = null ) { return array_key_exists ( $ name , $ this -> extra ) ? $ this -> extra [ $ name ] : $ default ; }
Get extra value if specified
3,910
protected function fetchPropel ( ) { if ( ! $ this -> hasOption ( 'propel' ) ) { return $ this ; } $ config = $ this -> getOption ( 'propel' ) ; if ( ! isset ( $ config [ 'class_name' ] ) ) { throw new OptionRequiredException ( 'Propel menu item requires "propel/class_name" config value in menu config' ) ; } elseif ( !...
Fetch the item s propel option and sub options .
3,911
protected function generatePropelChildren ( ) { if ( null === $ this -> propelClassName ) { return ; } $ queryClass = $ this -> propelClassName . 'Query' ; $ query = $ queryClass :: create ( ) ; foreach ( $ this -> propelQueryMethods as $ method => $ params ) { call_user_func_array ( array ( $ query , $ method ) , $ pa...
Generate propel children if the specific config was set .
3,912
protected function fetchParent ( ) { $ parent = $ this -> getOption ( 'parent' ) ; if ( $ parent instanceof MenuItem ) { $ this -> setParentItem ( $ parent ) ; } return $ this ; }
Check for parent item .
3,913
protected function fetchItemVariantDivider ( ) { if ( $ this -> getOption ( 'is_divider' ) || substr ( $ this -> getRouteName ( ) , 0 , 8 ) == '.divider' ) { $ this -> isDivider = true ; $ this -> options [ 'title' ] = 'dummy' ; } return $ this ; }
If the routename start with . divider the item will be used as a divider .
3,914
protected function fetchItemVariantHeadline ( ) { if ( $ this -> getOption ( 'is_section_header' ) || substr ( $ this -> getRouteName ( ) , 0 , 7 ) == '.header' ) { $ this -> isSectionHeader = true ; } return $ this ; }
If the routename start with . headline the item will be used as a section header .
3,915
protected function fetchRequireRouteName ( ) { $ this -> fetchOption ( 'requireRouteName' ) ; if ( '' != $ this -> requireRouteName && '!' == substr ( $ this -> requireRouteName , 0 , 1 ) ) { $ this -> invertRequireRouteName = true ; $ this -> requireRouteName = substr ( $ this -> requireRouteName , 1 ) ; } return $ th...
Fetch the item s require_route_name option .
3,916
protected function getCustomUrl ( array $ urlParameters = array ( ) ) { $ urlParameters = $ this -> addRequestVariablesToUrlParameters ( $ urlParameters ) ; if ( $ this -> customUrl && count ( $ urlParameters ) > 0 ) { $ params = http_build_query ( $ urlParameters ) ; if ( '' != parse_url ( $ this -> customUrl , PHP_UR...
Get the item s custom url to use instead of the routing .
3,917
protected function isMatchingRequestVariables ( ) { foreach ( $ this -> getMatchRequestVariables ( ) as $ key => $ value ) { if ( $ this -> getRequest ( ) -> get ( $ key ) != $ value ) { return false ; } } return true ; }
Check if the current request is matching all required vars .
3,918
protected function fetchOption ( $ name , $ required = false ) { $ optionName = Container :: underscore ( $ name ) ; if ( $ this -> hasOption ( $ optionName ) ) { $ this -> $ name = $ this -> getOption ( $ optionName ) ; } elseif ( $ required ) { throw new OptionRequiredException ( sprintf ( 'The menu item option %s is...
Fetch an option value from the given options array . If the specific option is not set the default value initialized in the class is used . If the required argument is true and the option is not set an OptionRequiredException is thrown .
3,919
protected function isMatchingRouteName ( ) { return $ this -> getCurrentRouteName ( ) == $ this -> getRouteName ( ) || array_key_exists ( $ this -> getCurrentRouteName ( ) , $ this -> getAliasRouteNames ( ) ) ; }
Check if the given route name is matching the request route name or alias route names
3,920
public function isCurrentAncestor ( ) { if ( null === $ this -> isCurrentAnchestor ) { $ this -> isCurrentAnchestor = false ; foreach ( $ this -> getChildren ( ) as $ child ) { if ( $ child -> isOnCurrentPath ( ) ) { $ this -> isCurrentAnchestor = true ; break ; } } } return $ this -> isCurrentAnchestor ; }
Check if any of the child items of the current item are currently selected .
3,921
public function getCurrentRouteName ( ) { if ( null === $ this -> currentRouteName ) { $ this -> currentRouteName = $ this -> getRequest ( ) -> get ( '_route' ) ; } return $ this -> currentRouteName ; }
Get the current route name from the request .
3,922
protected function getRouter ( ) { if ( null === $ this -> router ) { $ this -> router = $ this -> getContainer ( ) -> get ( 'router' ) ; } return $ this -> router ; }
Fetch the router from the DI container .
3,923
protected function isSecurityGranted ( $ attributes , $ object = null ) { if ( null === $ this -> getSecurityContext ( ) -> getToken ( ) ) { return false ; } return $ this -> getSecurityContext ( ) -> isGranted ( $ attributes , $ object ) ; }
Check if the current security context contains the role . Checks for a NULL token first to avaid exception .
3,924
protected function generateUrl ( array $ urlParameters = array ( ) , $ absolute = false ) { $ url = $ this -> getCustomUrl ( $ urlParameters ) ; if ( $ url ) { return $ url ; } return $ this -> generateStandardUrl ( $ urlParameters ) ; }
Generate the URL for this item .
3,925
public function getChildren ( $ id ) { $ table = $ this -> getTable ( ) ; $ closure = $ table . '_closure' ; $ tableAlias = 'c' ; $ closureAlias = 'cc' ; $ primaryKey = $ this -> mapper -> getPrimaryKey ( $ table ) ; $ fluent = $ this -> connection -> command ( ) -> select ( '%n.*' , $ tableAlias ) -> from ( '%n AS %n'...
Return direct children of given root s id
3,926
public function isMethodAllowed ( string $ method ) : bool { $ methods = $ this -> getAllow ( ) ; if ( $ methods ) { return in_array ( strtoupper ( $ method ) , $ methods ) ; } return false ; }
Check if an HTTP method is allowed by checking the Allow response header .
3,927
public function getEvenementsLies ( $ idEvenement = 0 , $ afficheEvenementsAdressesLiees = true , $ params = array ( ) ) { $ sqlEvenementsAdresses = "" ; $ arrayEvenementsAdressesLiees = array ( ) ; if ( $ afficheEvenementsAdressesLiees ) { $ arrayEvenementsAdressesLiees = $ this -> getIdEvenementFromEvenementAdressesL...
renvoi les evenements lies enfants d un groupe d adresses
3,928
public function afficherListe ( $ criteres = array ( ) ) { $ html = "" ; $ evenement = new archiEvenement ( ) ; $ arrayListeEvenements = $ evenement -> getIdEvenementsFromRecherche ( $ criteres ) ; $ arrayListeEvenements = array_unique ( $ arrayListeEvenements ) ; $ adresse = new archiAdresse ( ) ; $ arrayListeGroupesE...
resultat de la recherche d evenements renvoi une liste d adresses
3,929
public function getIdAdresse ( $ idEvenement ) { if ( ! isset ( $ idEvenement ) ) { return false ; } $ idEvenementGroup = $ this -> getIdGroupeEvenement ( $ idEvenement ) ; $ requete = " SELECT idAdresse FROM _adresseEvenement WHERE idEvenement = $idEvenementGroup " ; $ result = $ this -> connexionBdd -> r...
Get id adresse from idEvenement
3,930
public function getArrayIdEvenement ( $ idEvenementGroupeAdresse ) { $ requete = " SELECT evt.idEvenement FROM evenements evt LEFT JOIN _evenementEvenement ee on ee.idEvenement = $idEvenementGroupeAdresse WHERE evt.idEvenement = ee.idEvenementAssocie " ; $ result = $ this -> connexionBdd -> requete ( $ requete ) ;...
Get an array of idEvenement related to an idEvenementGroupeAdresse
3,931
public function displaySingleEvent ( $ evenement ) { $ t = new Template ( 'modules/archi/templates/' ) ; $ t -> set_filenames ( ( array ( 'evenement' => 'evenement/singleEvent.tpl' ) ) ) ; $ t -> assign_block_vars ( 'evenement' , $ evenement [ 'evenementData' ] ) ; if ( isset ( $ evenement [ 'menuArray' ] ) ) { foreach...
Display a single event with event data in input
3,932
public function attachHandler ( $ name , callable $ callback , $ once = false ) { if ( ! isset ( $ this -> events [ $ name ] ) ) { if ( strpos ( $ name , '.' ) === false ) { throw new InvalidEventException ( 'Event subject "' . $ this -> subjectClass . '" does not have event "' . $ name . '"' ) ; } $ this -> events [ $...
Attach an event handler to an event .
3,933
public function detachHandler ( $ name , callable $ callback ) { if ( ! isset ( $ this -> events [ $ name ] ) ) { return false ; } $ index = array_search ( $ callback , $ this -> events [ $ name ] , true ) ; if ( $ index === false ) { return false ; } unset ( $ this -> events [ $ name ] [ $ index ] ) ; return true ; }
Detach an already attached event handler .
3,934
public function detachListener ( EventListener $ listener ) { foreach ( $ listener -> getEventHandlers ( ) as $ name => $ method ) { if ( ! is_string ( $ name ) ) { $ name = $ method ; if ( strpos ( $ method , '.' ) !== false ) { $ splits = explode ( '.' , $ method ) ; $ method = $ splits [ count ( $ splits ) - 1 ] ; }...
Detach all handlers implemented by an event listener .
3,935
public function trigger ( $ name , Event $ event = null ) { if ( ! isset ( $ event ) ) { $ event = new Event ( $ this -> subject ) ; } if ( isset ( $ this -> parent ) ) { if ( ! $ this -> parent -> trigger ( $ this -> subjectClass . '.' . $ name , $ event ) ) { return false ; } } if ( isset ( $ this -> events [ $ name ...
Execute all functions attached to an event .
3,936
public function find ( $ id ) { $ key = $ this -> getHash ( ) . $ id ; if ( $ this -> getFileManager ( ) -> has ( $ key ) ) { return $ this -> loadEntity ( $ key ) ; } return null ; }
Find an entity by ID
3,937
public function findAll ( ) { $ keys = $ this -> getFileManager ( ) -> keys ( ) ; $ entities = array ( ) ; if ( is_array ( $ keys ) ) { foreach ( $ keys as $ key ) { if ( preg_match ( '/^' . $ this -> getHash ( ) . '/' , $ key ) ) { $ entities [ ] = $ this -> loadEntity ( $ key ) ; } } } return $ entities ; }
Find all entities for a specific class
3,938
public function remove ( Instance $ instance ) { $ key = $ this -> getHash ( ) . $ instance -> getId ( ) ; if ( $ this -> getFileManager ( ) -> has ( $ key ) ) { $ this -> getFileManager ( ) -> delete ( $ key ) ; } }
Remove an instance
3,939
public function setChildren ( array $ channels = null ) { if ( $ channels != null ) { foreach ( $ channels as $ channel ) { $ channelHydrated = self :: $ manager -> hydrate ( $ channel ) ; $ this -> addChildren ( $ channelHydrated ) ; } } }
Set channels array
3,940
public function getUri ( ) { $ uri = trim ( $ this -> getRawUri ( ) ) ; if ( null !== parse_url ( $ uri , PHP_URL_SCHEME ) ) { return $ uri ; } if ( ! $ uri ) { return $ this -> currentUri ; } if ( '#' === $ uri [ 0 ] ) { return $ this -> cleanupAnchor ( $ this -> currentUri ) . $ uri ; } $ baseUri = $ this -> cleanupU...
Gets the URI associated with this link .
3,941
public function set ( string $ timezone ) : bool { $ auth = false ; try { if ( ! empty ( $ timezone ) ) { date_default_timezone_set ( $ timezone ) ; $ auth = true ; } } catch ( Exception $ ex ) { throw $ ex ; } return $ auth ; }
- Set timezone locale
3,942
public function approximateRuntime ( $ command ) { $ tasks = $ this -> Task -> find ( 'list' , array ( 'conditions' => array ( 'command' => $ command , 'status' => TaskType :: FINISHED , 'runtime >' => 0 ) , 'fields' => array ( 'id' , 'runtime' ) , 'limit' => Configure :: read ( 'Task.approximateLimit' ) , 'order' => a...
Approximate runtime of the command
3,943
protected function extractNamespace ( $ fullQualifiedNamespace ) { $ parts = explode ( '\\' , $ fullQualifiedNamespace ) ; $ copyParts = $ parts ; $ copyParts = array_splice ( $ copyParts , 0 , - 1 ) ; return [ 'namespace' => implode ( '\\' , $ copyParts ) , 'class' => end ( $ parts ) , 'full_qualified_namespace' => $ ...
Parses the full qualified namespace to the namespace class and the full qualified namespace
3,944
public function getById ( $ id ) { $ this -> _db -> query ( 'SELECT * FROM ' . $ this -> _dbConfig [ 'table' ] . ' WHERE ' . $ this -> _dbConfig [ 'id' ] . ' = :id' , [ ':id' => $ id ] ) ; $ row = $ this -> _db -> result ( ) ; if ( isset ( $ row [ 0 ] ) ) { $ row = $ row [ 0 ] -> getAll ( ) ; $ this -> _login = true ; ...
Initialize user by ID
3,945
public function saveToken ( $ token ) { $ rows = $ this -> _db -> query ( 'UPDATE ' . $ this -> _dbConfig [ 'table' ] . ' SET ' . $ this -> _dbConfig [ 'token' ] . ' = :tk' . ' WHERE ' . $ this -> _dbConfig [ 'id' ] . ' = :id' , [ ':tk' => $ token , ':id' => $ this -> _data [ 'id' ] ] ) ; if ( $ rows > 0 ) { $ this -> ...
Set TOKEN data key
3,946
public function getToken ( $ id ) { $ row = $ this -> _db -> query ( 'SELECT token FROM ' . $ this -> _dbConfig [ 'table' ] . ' WHERE ' . $ this -> _dbConfig [ 'id' ] . ' = :id' , [ ':id' => $ id ] ) ; if ( isset ( $ row [ 0 ] ) ) { $ row = $ row [ 0 ] -> getAll ( ) ; return $ row [ $ this -> _dbConfig [ 'token' ] ] ; ...
Get Token by id
3,947
public function save ( $ id = null ) { if ( $ id !== null ) { $ this -> _data [ 'id' ] = $ id ; } if ( $ this -> _data [ 'id' ] !== null ) { $ action = 'UPDATE ' ; $ where = ' WHERE ' . $ this -> _dbConfig [ 'id' ] . ' = :id' ; } else { $ action = 'INSERT INTO ' ; $ where = '' ; } $ cols = '' ; $ vals = [ ] ; foreach (...
Save this USER on DataBase
3,948
public static function formatPath ( $ path ) { if ( $ path == DIRECTORY_SEPARATOR ) { return $ path ; } return trim ( $ path ) ? rtrim ( trim ( $ path ) , DIRECTORY_SEPARATOR ) : '' ; }
Format path without last separator .
3,949
public function getKeyName ( ) { if ( isset ( $ this -> primaryKey ) ) return $ this -> primaryKey ; return 'id_' . str_replace ( '\\' , '' , snake_case ( class_basename ( $ this ) ) ) ; }
Get the primary key for the model .
3,950
public function getAllData ( ) { $ aReturn = Array ( ) ; foreach ( get_class_vars ( get_class ( ) ) as $ keyVars => $ valueVars ) { if ( $ keyVars != '_snmpHost' ) { $ indexVar = str_replace ( '_' , '' , $ keyVars ) ; $ aReturn [ $ indexVar ] = $ this -> { $ keyVars } ; } } return $ aReturn ; }
Return all data witch platform
3,951
public static function baseUri ( $ mode = null ) : string { switch ( $ mode ) { case 'dev' : self :: getInstance ( ) -> baseUri = 'https://openapi.alipaydev.com/gateway.do' ; break ; default : break ; } return self :: getInstance ( ) -> baseUri ; }
Alipay gateway .
3,952
public function getForm ( $ itemClass , $ action ) { $ itemMetaData = $ this -> itemMetaDataFactory -> getItemMetaData ( $ itemClass ) ; $ form = $ this -> formFactory -> create ( new RequestType ( $ itemMetaData ) , new Request ( ) , array ( 'action' => $ action , 'method' => 'GET' ) ) ; return $ form ; }
Get Search form
3,953
public static function parse ( $ data , $ format = 'json' ) { if ( ! array_key_exists ( $ format , self :: $ decoders ) ) { throw new Exception ( 'Invalid decoder.' ) ; } $ decoder = self :: $ decoders [ $ format ] ; $ input = file_put_contents ( '/tmp/input' , $ data ) ; $ params = "drafter -f {$format} /tmp/input" ; ...
Parses the MSON input into an array .
3,954
protected function normalizeMailArgs ( array $ args ) : array { if ( is_array ( $ args [ 0 ] ) ) { return $ args [ 0 ] ; } $ result = [ ] ; $ length = count ( $ args ) ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ result [ $ this -> argumentsMapping [ $ i ] ] = $ args [ $ i ] ; } return $ result ; }
Normalizes the arguments passed when invoking this plugin so that they can be treated in a consistent way
3,955
protected function applyArgsToMailService ( array $ args ) { if ( isset ( $ args [ 'body' ] ) ) { $ body = $ args [ 'body' ] ; if ( is_array ( $ body ) ) { $ charset = $ body [ 'charset' ] ?? MailServiceInterface :: DEFAULT_CHARSET ; if ( isset ( $ body [ 'content' ] ) && is_string ( $ body [ 'content' ] ) ) { $ this -...
Applies the arguments provided while invoking this plugin to the MailService discarding any previous configuration
3,956
public function store ( string $ timeZone , array $ locale , int $ errorReporting , $ globals , $ env , $ get , $ post , $ cookie , $ server , $ session , $ files , $ request ) { $ this -> timeZone = $ timeZone ; $ this -> locale = $ locale ; $ this -> errorReporting = intval ( $ errorReporting ) ; $ this -> globals = ...
Store the given environment data
3,957
public function reset ( ) { ini_set ( 'display_errors' , '0' ) ; error_reporting ( E_ALL ) ; ini_set ( 'zend.assertions' , '1' ) ; ini_set ( 'assert.exception' , '1' ) ; $ GLOBALS = $ this -> prepareGlobalForRetrieval ( $ this -> globals ) ; $ _ENV = $ this -> prepareGlobalForRetrieval ( $ this -> env ) ; $ _GET = $ th...
Reset the environment variables
3,958
protected function addConnectionsSection ( $ rootNode ) { $ rootNode -> fixXmlConfig ( 'connection' ) -> children ( ) -> arrayNode ( 'connections' ) -> useAttributeAsKey ( 'id' ) -> prototype ( 'array' ) -> children ( ) -> scalarNode ( 'class' ) -> defaultValue ( 'Mandango\Connection' ) -> end ( ) -> scalarNode ( 'serv...
Adds the configuration for the connections key
3,959
protected function addConnectionOptionsNode ( ) { $ builder = new TreeBuilder ( ) ; $ node = $ builder -> root ( 'options' ) ; $ node -> performNoDeepMerging ( ) -> addDefaultsIfNotSet ( ) -> children ( ) -> booleanNode ( 'connect' ) -> end ( ) -> scalarNode ( 'persist' ) -> end ( ) -> scalarNode ( 'timeout' ) -> end (...
Adds the NodeBuilder for the options key of a connection .
3,960
public static function create ( Command $ command ) : CommandMessage { $ timestamp = DateTime :: now ( ) ; $ id = MessageId :: generate ( ) ; $ metaData = MetaData :: create ( ) ; return new static ( $ id , $ timestamp , $ command , $ metaData ) ; }
Creates instance for a command
3,961
public function filter ( $ value ) { try { $ result = $ this -> normalizeDateTime ( $ value ) ; } catch ( \ Exception $ e ) { throw new Exception \ InvalidArgumentException ( 'Invalid date string provided' , $ e -> getCode ( ) , $ e ) ; } if ( $ result === false ) { return $ value ; } return $ result ; }
Filter a datetime string by normalizing it to the filters specified format
3,962
protected function normalizeDateTime ( $ value ) { if ( $ value === '' || $ value === null ) { return $ value ; } if ( ! is_string ( $ value ) && ! is_int ( $ value ) && ! $ value instanceof DateTime ) { return $ value ; } if ( is_int ( $ value ) ) { $ value = new DateTime ( '@' . $ value ) ; } elseif ( ! $ value insta...
Normalize the provided value to a formatted string
3,963
private function determineRouterScript ( $ router , $ env , SymfonyStyle $ io ) { if ( false === $ path = realpath ( $ router ) ) { $ io -> error ( sprintf ( 'The given router script "%s" does not exist.' , $ router ) ) ; return false ; } return $ path ; }
Determine the absolute file path for the router script using the environment to choose a standard script if no custom router script is specified .
3,964
private function createServerProcess ( SymfonyStyle $ io , $ address , $ documentRoot , $ router ) { $ finder = new PhpExecutableFinder ( ) ; if ( false === $ binary = $ finder -> find ( ) ) { $ io -> error ( 'Unable to find PHP binary to start server.' ) ; return ; } $ script = implode ( ' ' , array_map ( array ( 'Sym...
Creates a process to start PHP s built - in web server .
3,965
public function getCondensed ( ) { if ( $ this -> version === 4 ) { return $ this -> value ; } $ addr = preg_replace ( '/(^|:)0+(\d)/' , '\1\2' , $ this -> getExpanded ( ) ) ; if ( preg_match_all ( '/(?:^|:)(?:0(?::|$))+/' , $ addr , $ matches , PREG_OFFSET_CAPTURE ) ) { $ max = 0 ; $ pos = null ; foreach ( $ matches [...
All consecutive sections of zeroes are removed .
3,966
public function loadComposer ( ) { if ( $ ownVendor = $ this -> tryPath ( 'vendor/' , BootLoader :: RELATIVE | BootLoader :: VALIDATE ) ) { $ this -> autoLoader = require $ ownVendor . 'autoload.php' ; } else { $ this -> autoLoader = require $ this -> getPath ( '../../' , BootLoader :: RELATIVE | BootLoader :: VALIDATE...
requires the Autoload from composer
3,967
function toArray ( ) { $ parse = array ( 'scheme' => $ this -> getScheme ( ) , 'user_info' => $ this -> getUserInfo ( ) , 'host' => $ this -> getHost ( ) , 'port' => $ this -> getPort ( ) , 'path' => $ this -> getPath ( ) , 'query' => $ this -> getQuery ( ) -> toString ( ) , 'fragment' => $ this -> getFragment ( ) , 'a...
Get Array In Form Of AssocArray
3,968
function setScheme ( $ scheme ) { if ( $ scheme !== null ) $ scheme = $ this -> _filterScheme ( ( string ) $ scheme ) ; $ this -> scheme = $ scheme ; return $ this ; }
Set the URI scheme
3,969
function setHost ( $ host ) { if ( $ host !== null ) $ host = $ this -> _filterHost ( ( string ) $ host ) ; $ this -> host = $ host ; return $ this ; }
Set the URI host
3,970
function setPort ( $ port ) { if ( $ port !== null ) { if ( empty ( $ port ) && $ port !== 0 ) $ port = null ; elseif ( $ port < 1 || $ port > 65535 ) throw new \ InvalidArgumentException ( sprintf ( 'Invalid port "%d" specified; must be a valid TCP/UDP port' , $ port ) ) ; } $ this -> port = $ port ; return $ this ; }
Set the URI host port
3,971
function getPort ( $ preserve = false ) { $ scheme = $ this -> getScheme ( ) ; if ( ! $ scheme ) return $ this -> port ; if ( $ this -> port === null && $ preserve ) if ( array_key_exists ( $ scheme , self :: $ SCHEME ) ) return self :: $ SCHEME [ $ scheme ] ; return ( $ this -> port ) ? ( ( array_key_exists ( $ scheme...
Get the URI host port
3,972
public static function Epj ( $ dj1 , $ dj2 ) { $ epj ; $ epj = 2000.0 + ( ( $ dj1 - DJ00 ) + $ dj2 ) / DJY ; return $ epj ; }
- - - - - - - i a u E p j - - - - - - -
3,973
public static function fromArray ( array $ properties , $ discardInvalidEntries = false ) { $ selfClass = get_called_class ( ) ; $ obj = new $ selfClass ( ) ; foreach ( $ properties as $ property => $ value ) { if ( ( ! property_exists ( get_called_class ( ) , $ property ) ) && $ discardInvalidEntries ) { continue ; } ...
Populate the StructClass s properties from an array
3,974
public function toArray ( ) { $ ret = [ ] ; foreach ( $ this as $ key => $ value ) { $ ret [ $ key ] = $ value ; } return $ ret ; }
Convert to an array . This will include any protected or private properties as well as public . Normally this shouldn t be an issue as struct classes are usually intended to have all members public .
3,975
public function validate ( ) { if ( ! defined ( "structclass-AnnotationRegistry-initilised" ) ) { define ( "structclass-AnnotationRegistry-initilised" , true ) ; AnnotationRegistry :: registerLoader ( function ( $ class ) { return class_exists ( $ class ) ; } ) ; } $ validator = Validation :: createValidatorBuilder ( )...
Validate class using annotations
3,976
public function aujaSerialize ( ) { $ result = array ( ) ; $ result [ 'type' ] = $ this -> getType ( ) ; $ result [ $ this -> getType ( ) ] = $ this -> basicSerialize ( ) ; return $ result ; }
Returns a ready - to - use array to be provided to the Auja GUI .
3,977
public static function getVersion ( array $ server = null ) { $ protocol = static :: make ( $ server ) ; if ( ! preg_match ( '#\A(?:HTTP/)?(?P<version>\d{1}\.\d+)\Z#' , $ protocol , $ matches ) ) { throw new UnexpectedValueException ( sprintf ( 'Unrecognized protocol version "%s".' , $ server [ 'SERVER_PROTOCOL' ] ) ) ...
Gets the version of request protocol .
3,978
public static function make ( array $ server = null ) { if ( empty ( $ server ) ) { $ server = $ _SERVER ; } if ( isset ( $ server [ 'SERVER_PROTOCOL' ] ) ) { return $ server [ 'SERVER_PROTOCOL' ] ; } return 'HTTP/1.1' ; }
Makes the string that contains the request protocol .
3,979
public function getRoleAsString ( ) { $ options = self :: getRoleOptions ( ) ; return isset ( $ options [ $ this -> role ] ) ? $ options [ $ this -> role ] : '' ; }
Returns a string representation of the model s role
3,980
public function withDirectoryPosition ( $ key , $ value ) { $ clone = clone $ this ; if ( $ key === count ( $ clone -> info [ 'path' ] ) ) { $ clone -> info [ 'file' ] = $ value ; return $ clone ; } $ clone -> info [ 'path' ] [ $ key ] = $ value ; return $ clone ; }
Returns a clone with other directory in a specific position
3,981
public function getPath ( ) { $ path = ! empty ( $ this -> info [ 'path' ] ) ? '/' . implode ( '/' , $ this -> info [ 'path' ] ) . '/' : '/' ; if ( ! empty ( $ this -> info [ 'file' ] ) ) { $ path .= $ this -> info [ 'file' ] ; if ( ! empty ( $ this -> info [ 'extension' ] ) ) { $ path .= '.' . $ this -> info [ 'extens...
Return the url path
3,982
protected function buildUrl ( ) { $ url = '' ; if ( isset ( $ this -> info [ 'scheme' ] ) ) { $ url .= $ this -> info [ 'scheme' ] . '://' ; } if ( isset ( $ this -> info [ 'host' ] ) ) { $ url .= $ this -> info [ 'host' ] ; } $ url .= $ this -> getPath ( ) ; if ( ! empty ( $ this -> info [ 'query' ] ) ) { $ url .= '?'...
Build the url using the splitted data
3,983
protected function parseUrl ( $ url ) { if ( strpos ( $ url , '//' ) === 0 ) { $ url = "http:$url" ; } $ this -> info = parse_url ( $ url ) ; if ( isset ( $ this -> info [ 'query' ] ) ) { parse_str ( $ this -> info [ 'query' ] , $ this -> info [ 'query' ] ) ; array_walk_recursive ( $ this -> info [ 'query' ] , function...
Parse an url and split into different pieces
3,984
public function getAbsolute ( $ url ) { if ( empty ( $ url ) ) { return '' ; } if ( strpos ( $ url , 'data:' ) === 0 ) { return $ url ; } if ( preg_match ( '|^\w+://|' , $ url ) ) { return $ url ; } if ( strpos ( $ url , '://' ) === 0 ) { return $ this -> getScheme ( ) . $ url ; } if ( strpos ( $ url , '//' ) === 0 ) {...
Return an absolute url based in a relative
3,985
private function setPath ( $ path ) { $ parts = pathinfo ( $ path ) ; $ this -> info [ 'path' ] = [ ] ; if ( isset ( $ parts [ 'dirname' ] ) ) { foreach ( explode ( '/' , str_replace ( DIRECTORY_SEPARATOR , '/' , $ parts [ 'dirname' ] ) ) as $ dir ) { if ( $ dir !== '' ) { $ this -> info [ 'path' ] [ ] = $ dir ; } } } ...
Parses and adds path and file value
3,986
public function set ( $ key , $ value ) { if ( ! $ value instanceof EntityDescriptorInterface ) { throw new InvalidArgumentException ( "Invalid descriptor. DescriptorsCollection only accepts " . "EntityDescriptorInterface object." ) ; } return parent :: set ( $ key , $ value ) ; }
Puts a new element in the map .
3,987
public function listAction ( ) { $ this -> writeln ( "Here is a list of the available environments:" ) ; foreach ( ConfigService :: getAllEnvironments ( ) as $ env ) { $ this -> writeln ( " - " . $ env ) ; } }
Shows all available environments
3,988
public function setAction ( ) { if ( ! ConfigService :: isEnvironmentExists ( 'local' ) ) { if ( $ this -> confirm ( 'We need to create local environment to save your params. Ok' , true ) ) { ConfigService :: createEnvironment ( 'local' ) ; } ; } $ name = $ this -> ask ( 'Enter name of environment' ) ; $ config = Confi...
Set active environment
3,989
public static function ini ( $ test = null ) { self :: getSupported ( ) ; self :: $ lang = self :: detect ( $ test ) ; exception_if ( ! in_array ( self :: $ lang , self :: $ supported ) , LanguageNotSupportedException :: class , self :: $ lang ) ; self :: load ( ) ; }
Initiate the Lang class .
3,990
protected static function getSupported ( ) { $ folders = File :: directories ( root ( ) . 'resources/translator' ) ; foreach ( $ folders as $ folder ) { $ lang = explode ( root ( ) . 'resources/translator/' , $ folder ) ; self :: $ supported [ ] = $ lang [ 1 ] ; } }
Get supported langs used by the app .
3,991
public static function detect ( $ test = false ) { if ( $ test ) { return 'en' ; } $ key = self :: $ sessionName ; $ cookieName = self :: cookieName ( $ key ) ; if ( Session :: exists ( $ key ) ) { if ( ! in_array ( Session :: get ( $ key ) , self :: $ supported ) ) { Session :: put ( $ key , config ( 'lang.default' , ...
Detect the used language .
3,992
protected static function load ( ) { $ files = glob ( root ( ) . 'resources/translator/' . self :: $ lang . '/*.php' ) ; foreach ( $ files as $ file ) { $ words = need ( $ file ) ; $ filename = explode ( 'resources/translator/' . self :: $ lang . '/' , $ file ) ; $ filename = $ filename [ 1 ] ; $ filename = explode ( '...
Get all words in supported language .
3,993
public static function set ( $ lang ) { exception_if ( ! in_array ( $ lang , self :: $ supported ) , LanguageNotSupportedException :: class , $ lang ) ; Cookie :: create ( self :: $ cookieName , $ lang , config ( 'lang.lifetime' ) ) ; Session :: put ( self :: $ sessionName , $ lang ) ; self :: change ( $ lang ) ; retur...
Change tha languauge used .
3,994
public static function get ( $ key ) { exception_if ( ! array_has ( self :: $ words , $ key ) , LanguageKeyNotFoundException :: class , $ key ) ; return array_get ( self :: $ words , $ key ) ; }
Get the translate word by a key .
3,995
public static function change ( $ lang ) { exception_if ( ! in_array ( $ lang , self :: $ supported ) , LanguageNotSupportedException :: class , $ lang ) ; self :: $ lang = $ lang ; self :: $ words = [ ] ; self :: load ( ) ; return true ; }
Use a language temporarily .
3,996
public function getLabelName ( ) { if ( is_null ( $ this -> _labelName ) ) { $ this -> _labelName = $ this -> name ; $ storage = $ this -> storage ; if ( ! empty ( $ storage ) ) { if ( empty ( $ this -> _labelName ) ) { $ this -> _labelName = $ storage -> file_name ; } else { $ this -> _labelName .= " ({$storage->file_...
Get label name .
3,997
public function setLabelName ( $ value ) { if ( ! empty ( $ this -> name ) ) { $ this -> _labelName = $ this -> name . ' (' . $ value . ')' ; } else { $ this -> _labelName = $ value ; } }
Set label name .
3,998
public function getDownloadLink ( $ label = null , $ htmlAttributes = [ ] ) { if ( is_null ( $ label ) ) { $ label = $ this -> descriptor ; } return Html :: a ( $ label , [ '/object/view' , 'subaction' => 'download' , 'id' => $ this -> id ] ) ; }
Get download link .
3,999
private function jqSearchQuery ( ) { $ searchFilters = ( $ filters = \ Input :: get ( 'filters' ) ) ? $ filters : null ; if ( ! ( $ searchFilters != null ) || ( ! isset ( $ searchFilters [ 'rules' ] ) ) || ( ! is_array ( $ searchFilters [ 'rules' ] ) ) ) { return $ this ; } $ this -> setJqGridQuery ( $ this -> jqGridQu...
Build query for the search .