idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
26,900
public static function setEnvVariables ( ) { $ env_variables = [ ] ; if ( file_exists ( static :: projectRoot ( ) . '/.env' ) ) { $ env_variables = ( new Dotenv ( static :: projectRoot ( ) ) ) -> load ( ) ; } self :: $ projectEnv = $ env_variables ; }
Set Project - x environment variables .
26,901
public static function setDefaultServices ( $ container ) { $ project_root = self :: projectRoot ( ) ; $ container -> share ( 'projectXTemplate' , \ Droath \ ProjectX \ Template \ TemplateManager :: class ) ; $ container -> share ( 'projectXGitHubUserAuth' , \ Droath \ ProjectX \ Service \ GitHubUserAuthStore :: class ) ; $ container -> share ( 'projectXHostChecker' , \ Droath \ ProjectX \ Service \ HostChecker :: class ) ; $ container -> add ( 'projectXEngine' , function ( ) use ( $ container ) { return ( new \ Droath \ ProjectX \ Engine \ EngineTypeFactory ( $ container -> get ( 'projectXEngineResolver' ) ) ) -> createInstance ( ) ; } ) ; $ container -> share ( 'projectXEngineResolver' , \ Droath \ ProjectX \ Engine \ EngineTypeResolver :: class ) -> withArgument ( 'projectXFilesystemCache' ) ; $ container -> add ( 'projectXProject' , function ( ) use ( $ container ) { return ( new \ Droath \ ProjectX \ Project \ ProjectTypeFactory ( $ container -> get ( 'projectXProjectResolver' ) ) ) -> createInstance ( ) ; } ) ; $ container -> share ( 'projectXProjectResolver' , \ Droath \ ProjectX \ Project \ ProjectTypeResolver :: class ) -> withArgument ( 'projectXFilesystemCache' ) ; $ container -> add ( 'projectXPlatform' , function ( ) use ( $ container ) { return ( new PlatformTypeFactory ( $ container -> get ( 'projectXPlatformResolver' ) ) ) -> createInstance ( ) ; } ) ; $ container -> share ( 'projectXPlatformResolver' , PlatformTypeResolver :: class ) -> withArgument ( 'projectXFilesystemCache' ) ; $ container -> share ( 'projectXFilesystemCache' , \ Symfony \ Component \ Cache \ Adapter \ FilesystemAdapter :: class ) -> withArguments ( [ '' , 0 , "$project_root/.project-x/cache" ] ) ; }
Set default container services .
26,902
public static function taskLocations ( ) { $ locations = array_merge ( [ self :: projectRoot ( ) ] , self :: getEngineType ( ) -> taskDirectories ( ) , self :: getProjectType ( ) -> taskDirectories ( ) , self :: getPlatformType ( ) -> taskDirectories ( ) ) ; if ( self :: hasProjectConfig ( ) ) { $ locations [ ] = APP_ROOT . '/src/Task' ; } return array_filter ( $ locations ) ; }
Project task locations .
26,903
public static function getPlatformType ( ) { $ container = self :: getContainer ( ) ; $ builder = CollectionBuilder :: create ( $ container , false ) ; return $ container -> get ( 'projectXPlatform' ) -> setBuilder ( $ builder ) ; }
Get the project - x platform type .
26,904
public static function getProjectType ( ) { $ container = self :: getContainer ( ) ; $ builder = CollectionBuilder :: create ( $ container , new ProjectTasks ( ) ) ; return $ container -> get ( 'projectXProject' ) -> setBuilder ( $ builder ) ; }
Get project type instance .
26,905
public static function getEngineType ( ) { $ container = self :: getContainer ( ) ; $ builder = CollectionBuilder :: create ( $ container , new EngineTasks ( ) ) ; return $ container -> get ( 'projectXEngine' ) -> setBuilder ( $ builder ) ; }
Get engine type instance .
26,906
public static function getProjectConfig ( ) { if ( ! isset ( self :: $ projectConfig ) ) { $ config = self :: getConfigInstance ( ) ; $ values = self :: getLocalConfigValues ( ) ; self :: $ projectConfig = empty ( $ values ) ? $ config : $ config -> update ( $ values ) ; } return self :: $ projectConfig ; }
Get Project - X configuration .
26,907
public static function getRemoteEnvironments ( ) { $ environments = [ ] ; foreach ( self :: getProjectConfig ( ) -> getRemote ( ) as $ remote ) { foreach ( $ remote as $ environment ) { if ( ! isset ( $ environment [ 'realm' ] ) ) { continue ; } $ realm = $ environment [ 'realm' ] ; unset ( $ environment [ 'realm' ] ) ; $ environments [ $ realm ] [ ] = $ environment ; } } return $ environments ; }
Get Project - X remote environments .
26,908
protected static function getLocalConfigValues ( ) { $ root = self :: projectRoot ( ) ; $ path = "{$root}/project-x.local.yml" ; if ( ! file_exists ( $ path ) ) { return [ ] ; } $ instance = ProjectXConfig :: createFromFile ( new \ SplFileInfo ( $ path ) ) ; return array_filter ( $ instance -> toArray ( ) ) ; }
Get local configuration values .
26,909
public function getCurrentFailAttemptCount ( ) { if ( ! $ this -> sessionBag -> has ( self :: PARAM_ATTEMPT_NS ) ) { $ this -> reset ( ) ; } return $ this -> sessionBag -> get ( self :: PARAM_ATTEMPT_NS ) ; }
Returns current fail attempt count
26,910
public function getLastLogin ( ) { if ( $ this -> sessionBag -> has ( self :: PARAM_LAST_LOGIN_NS ) ) { return $ this -> sessionBag -> get ( self :: PARAM_LAST_LOGIN_NS ) ; } else { return null ; } }
Returns last login
26,911
public function fromList ( $ value ) : self { $ value = collect ( $ value ) -> implode ( self :: SEPARATOR ) ; $ this -> has ( "list:{$value}" ) ; return $ this ; }
Filter a message if it was sent from a mailing list .
26,912
public static function humanSize ( $ bytes ) { if ( $ bytes == 0 ) { return '0 B' ; } $ value = floor ( log ( $ bytes , 1024 ) ) ; $ units = array ( 'B' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' , 'EB' , 'ZB' , 'YB' ) ; $ unit = $ units [ $ value ] ; return sprintf ( '%.02F' , $ bytes / pow ( 1024 , $ value ) ) * 1 . ' ' . $ unit ; }
Turns raw bytes into human - readable format
26,913
public static function hasExtension ( $ baseName , array $ extensions ) { $ baseName = strtolower ( $ baseName ) ; $ extensions = array_map ( function ( $ key ) { return strtolower ( $ key ) ; } , $ extensions ) ; return in_array ( self :: getExtension ( $ baseName ) , $ extensions ) ; }
Checks whether file has extension
26,914
public static function getMimeType ( $ file ) { $ mimeType = new MimeTypeGuesser ( ) ; $ extension = self :: getExtension ( $ file ) ; return $ mimeType -> getTypeByExtension ( $ file ) ; }
Fetches mime type from a file
26,915
public static function rmfile ( $ file ) { if ( is_file ( $ file ) ) { return chmod ( $ file , 0777 ) && unlink ( $ file ) ; } else { throw new RuntimeException ( sprintf ( 'Invalid file path supplied "%s"' , $ file ) ) ; } }
Safely removes a file
26,916
public static function getDirTree ( $ dir , $ self = false ) { if ( ! is_dir ( $ dir ) ) { throw new RuntimeException ( sprintf ( 'Can not build directory tree because of invalid path "%s"' , $ dir ) ) ; } $ target = array ( ) ; $ tree = array ( ) ; $ iterator = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ dir , RecursiveDirectoryIterator :: SKIP_DOTS ) , RecursiveIteratorIterator :: SELF_FIRST ) ; if ( $ self !== false ) { array_push ( $ target , $ dir ) ; } foreach ( $ iterator as $ file ) { array_push ( $ target , $ file ) ; } foreach ( $ target as $ index => $ file ) { array_push ( $ tree , ( string ) $ file ) ; } return $ tree ; }
Builds directory tree
26,917
public static function getDirSizeCount ( $ dir ) { if ( ! is_dir ( $ dir ) ) { throw new RuntimeException ( sprintf ( 'Invalid directory path supplied "%s"' , $ dir ) ) ; } $ count = 0.00 ; $ iterator = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ dir ) ) ; foreach ( $ iterator as $ file ) { $ count += $ file -> getSize ( ) ; } return $ count ; }
Counts directory size in bytes
26,918
public static function chmod ( $ file , $ mode , array & $ ignored = array ( ) ) { if ( is_file ( $ file ) ) { if ( ! chmod ( $ file , $ mode ) ) { array_push ( $ ignored , $ file ) ; return false ; } } else if ( is_dir ( $ file ) ) { $ items = self :: getDirTree ( $ file , true ) ; foreach ( $ items as $ item ) { if ( ! chmod ( $ item , $ mode ) ) { array_push ( $ ignored , $ item ) ; } } } else { throw new UnexpectedValueException ( sprintf ( '%s expects a path to be a directory or a file as first argument' , __METHOD__ ) ) ; } return true ; }
Recursively applies chmod to given directory
26,919
public static function copy ( $ src , $ dst ) { if ( ! is_dir ( $ src ) ) { throw new RuntimeException ( sprintf ( 'Invalid directory path supplied "%s"' , $ src ) ) ; } $ dir = opendir ( $ src ) ; if ( ! is_dir ( $ dst ) ) { mkdir ( $ dst , 0777 ) ; } while ( false !== ( $ file = readdir ( $ dir ) ) ) { if ( ( $ file != '.' ) && ( $ file != '..' ) ) { if ( is_dir ( $ src . '/' . $ file ) ) { call_user_func ( __METHOD__ , $ src . '/' . $ file , $ dst . '/' . $ file ) ; } else { copy ( $ src . '/' . $ file , $ dst . '/' . $ file ) ; } } } closedir ( $ dir ) ; return true ; }
Copies a directory to another directory
26,920
public static function move ( $ from , $ to ) { return self :: copy ( $ from , $ to ) && self :: delete ( $ from ) ; }
Moves a directory
26,921
public static function isFileEmpty ( $ file ) { if ( ! is_file ( $ file ) ) { throw new RuntimeException ( sprintf ( 'Invalid file path supplied' ) ) ; } return mb_strlen ( file_get_contents ( $ file , 2 ) , 'UTF-8' ) > 0 ? false : true ; }
Checks whether file is empty
26,922
public static function getFirstLevelDirs ( $ dir ) { $ iterator = new DirectoryIterator ( $ dir ) ; $ result = array ( ) ; foreach ( $ iterator as $ item ) { if ( ! $ item -> isDot ( ) && $ item -> isDir ( ) ) { array_push ( $ result , $ item -> getFileName ( ) ) ; } } return $ result ; }
Returns nested directories inside provided one
26,923
public function summaryFields ( ) { $ summaryFields = parent :: summaryFields ( ) ; $ summaryFields = array_merge ( $ summaryFields , array ( 'Title' => _t ( 'News.TITLE' , 'Title' ) , 'Author' => _t ( 'News.AUTHOR' , 'Author' ) , 'PublishFrom' => _t ( 'News.PUBLISH' , 'Publish from' ) , 'Status' => _t ( 'News.STATUS' , 'Status' ) , ) ) ; return $ summaryFields ; }
Define sumaryfields ;
26,924
public function searchableFields ( ) { $ searchableFields = parent :: searchableFields ( ) ; unset ( $ searchableFields [ 'PublishFrom' ] ) ; $ searchableFields [ 'Title' ] = array ( 'field' => 'TextField' , 'filter' => 'PartialMatchFilter' , 'title' => _t ( 'News.TITLE' , 'Title' ) ) ; $ searchableFields [ 'Author' ] = array ( 'field' => 'TextField' , 'filter' => 'PartialMatchFilter' , 'title' => _t ( 'News.AUTHOR' , 'Author' ) ) ; return $ searchableFields ; }
Define translatable searchable fields
26,925
public function fieldLabels ( $ includerelations = true ) { $ labels = parent :: fieldLabels ( $ includerelations ) ; $ newsLabels = array ( 'Title' => _t ( 'News.TITLE' , 'Title' ) , 'Author' => _t ( 'News.AUTHOR' , 'Author' ) , 'Synopsis' => _t ( 'News.SUMMARY' , 'Summary/Abstract' ) , 'Content' => _t ( 'News.CONTENT' , 'Content' ) , 'PublishFrom' => _t ( 'News.PUBDATE' , 'Publish from' ) , 'Live' => _t ( 'News.PUSHLIVE' , 'Published' ) , 'Commenting' => _t ( 'News.COMMENTING' , 'Allow comments on this item' ) , 'Type' => _t ( 'News.NEWSTYPE' , 'Type of item' ) , 'External' => _t ( 'News.EXTERNAL' , 'External link' ) , 'Download' => _t ( 'News.DOWNLOAD' , 'Downloadable file' ) , 'Impression' => _t ( 'News.IMPRESSION' , 'Impression image' ) , 'Comments' => _t ( 'News.COMMENTS' , 'Comments' ) , 'SlideshowImages' => _t ( 'News.SLIDE' , 'Slideshow' ) , 'Tags' => _t ( 'News.TAGS' , 'Tags' ) , 'NewsHolderPages' => _t ( 'News.LINKEDPAGES' , 'Linked pages' ) , 'Help' => _t ( 'News.BASEHELPLABEL' , 'Help' ) ) ; return array_merge ( $ newsLabels , $ labels ) ; }
Setup the fieldlabels and their translation .
26,926
public function onBeforeWrite ( ) { parent :: onBeforeWrite ( ) ; if ( ! $ this -> NewsHolderPages ( ) -> count ( ) ) { if ( ! class_exists ( 'Translatable' ) && $ page = NewsHolderPage :: get ( ) -> first ( ) ) { $ this -> NewsHolderPages ( ) -> add ( $ page ) ; } elseif ( class_exists ( 'Translatable' ) ) { Translatable :: disable_locale_filter ( ) ; $ page = NewsHolderPage :: get ( ) -> first ( ) ; $ this -> NewsHolderPages ( ) -> add ( $ page ) ; Translatable :: enable_locale_filter ( ) ; } } if ( ! $ this -> Type || $ this -> Type === '' ) { $ this -> Type = 'news' ; } if ( ! $ this -> PublishFrom ) { $ this -> PublishFrom = SS_Datetime :: now ( ) -> Rfc2822 ( ) ; } if ( substr ( $ this -> External , 0 , 4 ) !== 'http' && $ this -> External != '' ) { $ this -> External = 'http://' . $ this -> External ; } $ this -> setURLValue ( ) ; $ this -> setAuthorData ( ) ; }
The holder - page ID should be set if translatable otherwise we just select the first available one . The NewsHolderPage should NEVER be doubled .
26,927
private function setURLValue ( ) { if ( ! $ this -> URLSegment || ( $ this -> isChanged ( 'Title' ) && ! $ this -> isChanged ( 'URLSegment' ) ) ) { if ( $ this -> ID > 0 ) { $ Renamed = new Renamed ( ) ; $ Renamed -> OldLink = $ this -> URLSegment ; $ Renamed -> NewsID = $ this -> ID ; $ Renamed -> write ( ) ; $ this -> URLSegment = singleton ( 'SiteTree' ) -> generateURLSegment ( $ this -> Title ) ; if ( strpos ( $ this -> URLSegment , 'page-' ) === false ) { $ URLSegment = $ this -> URLSegment ; if ( $ this -> LookForExistingURLSegment ( $ URLSegment ) ) { $ URLSegment = $ this -> URLSegment . '-' . $ this -> ID ; } $ this -> URLSegment = $ URLSegment ; } } } }
Setup the URLSegment for this item and create a Renamed Object if it s a rename - action .
26,928
private function LookForExistingURLSegment ( $ URLSegment ) { return ( News :: get ( ) -> filter ( array ( 'URLSegment' => $ URLSegment ) ) -> exclude ( array ( 'ID' => $ this -> ID ) ) -> count ( ) !== 0 ) ; }
test whether the URLSegment exists already on another Newsitem
26,929
public function LinkingMode ( ) { $ controller = Controller :: curr ( ) ; $ params = $ controller -> getURLParams ( ) ; return $ params [ 'ID' ] === $ this -> URLSegment ? 'current' : 'link' ; }
Setup the LinkingMode for menu - items .
26,930
public function getStatus ( ) { $ published = $ this -> isPublished ( ) ? _t ( 'News.IsPublished' , 'published' ) : _t ( 'News.IsUnpublished' , 'not published' ) ; if ( $ this -> isPublished ( ) && $ this -> PublishFrom > SS_Datetime :: now ( ) -> Rfc2822 ( ) ) { $ published = _t ( 'News.InQueue' , 'Awaiting publishdate' ) ; } return $ published ; }
Returns if the news item is published or not
26,931
public function doPublish ( ) { if ( ! $ this -> canEdit ( ) ) { throw new ValidationException ( _t ( 'News.PublishPermissionFailure' , 'No permission to publish or unpublish news item' ) ) ; } $ this -> Live = true ; $ this -> write ( ) ; }
Publishes a news item
26,932
public function doUnpublish ( ) { if ( ! $ this -> canEdit ( ) ) { throw new ValidationException ( _t ( 'News.PublishPermissionFailure' , 'No permission to publish or unpublish news item' ) ) ; } $ this -> Live = false ; $ this -> write ( ) ; }
Unpublishes an news item
26,933
public static function CreateFreePostageObject ( ) { $ postage = new PostageArea ( ) ; $ postage -> ID = - 1 ; $ postage -> Title = _t ( "Checkout.FreeShipping" , "Free Shipping" ) ; $ postage -> Country = "*" ; $ postage -> ZipCode = "*" ; return $ postage ; }
Generate a free postage object we can use in our code .
26,934
public static function create ( string $ basePath ) : Application { self :: $ instance = new Application ( $ basePath ) ; return self :: $ instance ; }
Creates a new application
26,935
public function basePath ( ? string $ basePath = null ) { if ( $ basePath != null ) { $ this -> basePath = $ basePath ; } return $ this -> basePath ; }
Set or returns the application base path
26,936
public function storagePath ( ? string $ storagePath = null ) { if ( $ storagePath != null ) { $ this -> storagePath = $ storagePath ; } else if ( ! isset ( $ this -> storagePath ) ) { $ this -> storagePath = get_property ( "app.storage_path" , $ this -> basePath . DIRECTORY_SEPARATOR . "storage" ) ; } return $ this -> storagePath ; }
Set or returns the storage path
26,937
public function resourcesPath ( ? string $ resourcesPath = null ) { if ( $ resourcesPath != null ) { $ this -> resourcesPath = $ resourcesPath ; } else if ( ! isset ( $ this -> resourcesPath ) ) { $ this -> resourcesPath = get_property ( "app.resources_path" , $ this -> basePath . DIRECTORY_SEPARATOR . "resources" ) ; } return $ this -> resourcesPath ; }
Set or returns the resources path
26,938
public function configPath ( ? string $ configPath = null ) { if ( $ configPath != null ) { $ this -> configPath = $ configPath ; } else { if ( ! isset ( $ this -> configPath ) ) { $ this -> configPath = $ this -> basePath ( ) . DIRECTORY_SEPARATOR . "config" ; } } return $ this -> configPath ; }
Set or returns the config path
26,939
public function localConfigPath ( ? string $ localConfigPath = null ) { if ( $ localConfigPath != null ) { $ this -> localConfigPath = $ localConfigPath ; } else { if ( ! isset ( $ this -> localConfigPath ) ) { $ this -> localConfigPath = $ this -> basePath ( ) . DIRECTORY_SEPARATOR . "config.local" ; } } return $ this -> localConfigPath ; }
Set or returns the local config path
26,940
public function start ( ) { foreach ( $ this -> modules as $ module ) { $ module -> start ( ) ; } if ( php_sapi_name ( ) == "cli" ) { Commands :: handleCommand ( ) ; } else { Routes :: handleRequest ( ) ; } }
Initializes the application
26,941
private function getParameterValues ( $ function , array $ parameters = [ ] ) { $ functionParams = [ ] ; $ parameterIndex = 0 ; foreach ( $ function -> getParameters ( ) as $ parameter ) { $ parameterName = $ parameter -> getName ( ) ; $ parameterValue = null ; if ( array_key_exists ( $ parameterName , $ parameters ) ) { $ parameterValue = $ parameters [ $ parameterName ] ; } else if ( $ parameter -> hasType ( ) ) { $ type = $ parameter -> getType ( ) ; if ( ! $ type -> isBuiltin ( ) ) { $ typeName = ( string ) $ type ; if ( array_key_exists ( $ typeName , $ parameters ) ) { $ parameterValue = $ parameters [ $ typeName ] ; } else if ( ! $ parameter -> isDefaultValueAvailable ( ) ) { $ typeClass = new ReflectionClass ( $ typeName ) ; foreach ( $ typeClass -> getMethods ( ReflectionMethod :: IS_STATIC ) as $ staticMethod ) { if ( $ staticMethod -> getReturnType ( ) != null && ( ( string ) $ staticMethod -> getReturnType ( ) == $ typeName ) && $ staticMethod -> getNumberOfParameters ( ) == 0 ) { $ parameterValue = $ staticMethod -> invoke ( null ) ; break ; } } } } } if ( $ parameterValue == null ) { if ( array_key_exists ( $ parameterIndex , $ parameters ) ) { $ parameterValue = $ parameters [ $ parameterIndex ] ; $ parameterIndex ++ ; } else if ( $ parameter -> isDefaultValueAvailable ( ) ) { $ parameterValue = $ parameter -> getDefaultValue ( ) ; } } $ functionParams [ ] = $ parameterValue ; } return $ functionParams ; }
Returns the parameters values for a function
26,942
public function handleError ( $ errno , $ errstr , $ errfile , $ errline , $ errcontext ) { throw new ErrorException ( $ errstr , 0 , $ errno , $ errfile , $ errline ) ; }
Handles an application error
26,943
public function translate ( $ text , $ autoDetect = true ) { if ( ! $ this -> getTargetLang ( ) ) { throw new TranslateException ( 'No target language was set.' ) ; } if ( ! $ this -> getSourceLang ( ) && $ autoDetect ) { $ this -> setSourceLang ( $ this -> detect ( $ text ) ) ; } else { if ( ! $ this -> getSourceLang ( ) ) { throw new TranslateException ( 'No source language was set with autodetect turned off.' ) ; } } $ requestUrl = $ this -> buildRequestUrl ( $ this -> getTranslateUrl ( ) , [ 'q' => $ text , 'source' => $ this -> getSourceLang ( ) , 'target' => $ this -> getTargetLang ( ) ] ) ; $ response = $ this -> getResponse ( $ requestUrl ) ; if ( isset ( $ response [ 'data' ] [ 'translations' ] ) && count ( $ response [ 'data' ] [ 'translations' ] ) > 0 ) { return $ response [ 'data' ] [ 'translations' ] [ 0 ] [ 'translatedText' ] ; } return null ; }
Translates provided textual string
26,944
public function detect ( $ text ) { $ requestUrl = $ this -> buildRequestUrl ( $ this -> getDetectUrl ( ) , [ 'q' => $ text ] ) ; $ response = $ this -> getResponse ( $ requestUrl ) ; if ( isset ( $ response [ 'data' ] [ 'detections' ] ) ) { return $ response [ 'data' ] [ 'detections' ] [ 0 ] [ 0 ] [ 'language' ] ; } throw new TranslateException ( 'Could not detect provided text language.' ) ; }
Detects language of specified text string
26,945
protected function getResponse ( $ requestUrl ) { $ response = $ this -> getHttpClient ( ) -> get ( $ requestUrl ) ; return json_decode ( $ response -> getBody ( ) -> getContents ( ) , true ) ; }
Sends request to provided request url and gets json array
26,946
public function setQuery ( $ query ) { $ this -> cacheRows = null ; $ this -> size = null ; $ this -> paginator = new Paginator ( $ query ) ; return $ this ; }
Set query .
26,947
public function violate ( $ message ) { if ( ! empty ( $ this -> messages ) ) { $ message = $ this -> messages [ 0 ] ; } else { $ this -> setMessage ( $ message ) ; } }
Notifies about constraint violation
26,948
public function applyToChildNodes ( $ parentId , Closure $ callback ) { $ ids = $ this -> findChildNodeIds ( $ parentId ) ; if ( ! empty ( $ ids ) ) { foreach ( $ ids as $ id ) { $ callback ( $ id ) ; } } return true ; }
Applies user - defined callback function to each node
26,949
public function findParentNodesByChildId ( $ id ) { $ result = array ( ) ; $ rl = $ this -> getRelations ( ) ; $ data = $ rl [ RelationBuilder :: TREE_PARAM_ITEMS ] ; if ( ! isset ( $ data [ $ id ] ) ) { return array ( ) ; } $ current = $ data [ $ id ] ; $ parentId = $ current [ RelationBuilder :: TREE_PARAM_PARENT_ID ] ; while ( isset ( $ data [ $ parentId ] ) ) { $ current = $ data [ $ parentId ] ; $ parentId = $ current [ RelationBuilder :: TREE_PARAM_PARENT_ID ] ; array_push ( $ result , $ current ) ; } return $ result ; }
Finds all child nodes
26,950
public function findAll ( $ id ) { $ result = array ( ) ; $ root = $ this -> findById ( $ id ) ; if ( $ root !== false ) { $ result = array_merge ( $ result , array ( $ root ) ) ; } return array_merge ( $ result , $ this -> findParentNodesByChildId ( $ id ) ) ; }
Finds all matches This method is useful for making breadcrumbs
26,951
public function findById ( $ id ) { $ result = array ( ) ; $ relations = $ this -> getRelations ( ) ; $ items = $ relations [ RelationBuilder :: TREE_PARAM_ITEMS ] ; if ( isset ( $ items [ $ id ] ) ) { return $ items [ $ id ] ; } else { return false ; } }
Finds a node by its associated id
26,952
public function render ( AbstractRenderer $ renderer = null , $ active = null ) { if ( is_null ( $ renderer ) ) { $ renderer = $ this -> getRenderer ( ) ; } return $ renderer -> render ( $ this -> getRelations ( ) , $ active ) ; }
Renders an interface
26,953
private function getRelations ( ) { if ( is_null ( $ this -> relations ) ) { $ builder = new RelationBuilder ( ) ; $ this -> relations = $ builder -> build ( $ this -> data ) ; } return $ this -> relations ; }
Returns relations lazily
26,954
private function findChildNodeWithKey ( $ parentId , $ key ) { $ result = array ( ) ; $ relations = $ this -> getRelations ( ) ; if ( isset ( $ relations [ RelationBuilder :: TREE_PARAM_PARENTS ] [ $ parentId ] ) ) { foreach ( $ relations [ RelationBuilder :: TREE_PARAM_PARENTS ] [ $ parentId ] as $ id ) { $ node = $ relations [ RelationBuilder :: TREE_PARAM_ITEMS ] [ $ id ] [ $ key ] ; $ result = array_merge ( $ result , $ this -> findChildNodeWithKey ( $ id , $ key ) ) ; $ result [ ] = $ node ; } } return $ result ; }
Finds all child nodes including a key
26,955
public function toProtobufRequest ( ) { $ request = new \ POGOProtos \ Networking \ Requests \ Request ( ) ; $ request -> setRequestType ( $ this -> getType ( ) ) ; if ( ( $ message = $ this -> getMessage ( ) ) !== null ) { $ request -> setRequestMessage ( $ message -> toStream ( ) ) ; } return $ request ; }
Converts Rpc Request to protobuf request
26,956
final protected function loadArray ( $ file ) { if ( is_file ( $ file ) ) { $ array = include ( $ file ) ; if ( is_array ( $ array ) ) { return $ array ; } else { trigger_error ( sprintf ( 'Included file "%s" should return an array not %s' , $ file , gettype ( $ array ) ) ) ; } } else { return array ( ) ; } }
Safely loads an array from a file
26,957
final public function getConfig ( $ key = null ) { if ( method_exists ( $ this , 'getConfigData' ) ) { if ( $ this -> config === null ) { $ this -> config = $ this -> getConfigData ( ) ; if ( ! is_array ( $ this -> config ) ) { throw new LogicException ( 'Configuration provider should return an array' ) ; } } if ( ! is_null ( $ key ) ) { if ( isset ( $ this -> config [ $ key ] ) ) { return $ this -> config [ $ key ] ; } else { trigger_error ( 'Attempted to read non-existing configuration key' ) ; } } else { return $ this -> config ; } } else { throw new RuntimeException ( sprintf ( 'If you want to read configuration from modules, you should implement provideConfig() method that returns an array in %s' , null ) ) ; } }
Returns module configuration key
26,958
final public function hasConfig ( $ key = null ) { $ config = $ this -> getConfig ( ) ; if ( is_null ( $ key ) ) { return ! empty ( $ config ) ; } else { return array_key_exists ( $ key , $ config ) ; } }
Checks whether either configuration key exists or config is not empty
26,959
final public function getServices ( ) { if ( is_null ( $ this -> serviceProviders ) ) { $ this -> serviceProviders = $ this -> getServiceProviders ( ) ; } return $ this -> serviceProviders ; }
Returns all registered service providers
26,960
public function register ( $ name , $ handler ) { if ( is_callable ( $ handler ) ) { $ params = array_merge ( array ( $ this ) , $ this -> params ) ; $ this -> container [ $ name ] = call_user_func_array ( $ handler , $ params ) ; } else { $ this -> container [ $ name ] = $ handler ; } return $ this ; }
Registers a service
26,961
public function registerCollection ( array $ collection ) { foreach ( $ collection as $ name => $ handler ) { $ this -> register ( $ name , $ handler ) ; } return $ this ; }
Registers a collection of services
26,962
public function get ( $ name ) { if ( $ this -> exists ( $ name ) ) { return $ this -> container [ $ name ] ; } else { throw new RuntimeException ( sprintf ( 'Attempted to retrieve non-existing dependency "%s"' , $ name ) ) ; } }
Returns a service by its name
26,963
private function makeDestination ( $ id , $ width , $ height ) { return sprintf ( '%s/%s/%sx%s' , $ this -> dir , $ id , $ width , $ height ) ; }
Makes destination folder
26,964
public function upload ( $ id , array $ files ) { foreach ( $ files as $ file ) { if ( $ file instanceof FileEntity ) { foreach ( $ this -> dimensions as $ index => $ dimension ) { $ width = ( int ) $ dimension [ 0 ] ; $ height = ( int ) $ dimension [ 1 ] ; $ destination = $ this -> makeDestination ( $ id , $ width , $ height ) ; if ( ! is_dir ( $ destination ) ) { mkdir ( $ destination , 0777 , true ) ; } $ to = sprintf ( '%s/%s' , $ destination , $ file -> getUniqueName ( ) ) ; $ imageProcessor = new ImageProcessor ( $ file -> getTmpName ( ) ) ; $ imageProcessor -> thumb ( $ width , $ height ) ; $ imageProcessor -> save ( $ to , $ this -> quality ) ; } } } return true ; }
Upload images from the input
26,965
protected function getCountryNames ( $ language ) { $ event = new LoadLanguageFileEvent ( 'countries' , $ language , true ) ; $ this -> eventDispatcher -> dispatch ( ContaoEvents :: SYSTEM_LOAD_LANGUAGE_FILE , $ event ) ; return $ GLOBALS [ 'TL_LANG' ] [ 'CNT' ] ; }
Retrieve all country names in the given language .
26,966
protected function restoreLanguage ( ) { if ( $ this -> getMetaModel ( ) -> getActiveLanguage ( ) != $ GLOBALS [ 'TL_LANGUAGE' ] ) { $ event = new LoadLanguageFileEvent ( 'countries' , null , true ) ; $ this -> eventDispatcher -> dispatch ( ContaoEvents :: SYSTEM_LOAD_LANGUAGE_FILE , $ event ) ; } }
Restore the normal language values .
26,967
protected function getCountries ( ) { $ loadedLanguage = $ this -> getMetaModel ( ) -> getActiveLanguage ( ) ; if ( isset ( $ this -> countryCache [ $ loadedLanguage ] ) ) { return $ this -> countryCache [ $ loadedLanguage ] ; } $ languageValues = $ this -> getCountryNames ( $ loadedLanguage ) ; $ countries = $ this -> getRealCountries ( ) ; $ keys = \ array_keys ( $ countries ) ; $ aux = [ ] ; $ real = [ ] ; foreach ( $ keys as $ key ) { if ( isset ( $ languageValues [ $ key ] ) ) { $ aux [ $ key ] = Utf8 :: toAscii ( $ languageValues [ $ key ] ) ; $ real [ $ key ] = $ languageValues [ $ key ] ; } } $ keys = \ array_diff ( $ keys , \ array_keys ( $ aux ) ) ; if ( $ keys ) { $ loadedLanguage = $ this -> getMetaModel ( ) -> getFallbackLanguage ( ) ; $ fallbackValues = $ this -> getCountryNames ( $ loadedLanguage ) ; foreach ( $ keys as $ key ) { if ( isset ( $ fallbackValues [ $ key ] ) ) { $ aux [ $ key ] = Utf8 :: toAscii ( $ fallbackValues [ $ key ] ) ; $ real [ $ key ] = $ fallbackValues [ $ key ] ; } } } $ keys = \ array_diff ( $ keys , \ array_keys ( $ aux ) ) ; if ( $ keys ) { foreach ( $ keys as $ key ) { $ aux [ $ key ] = $ countries [ $ key ] ; $ real [ $ key ] = $ countries [ $ key ] ; } } \ asort ( $ aux ) ; $ return = [ ] ; foreach ( \ array_keys ( $ aux ) as $ key ) { $ return [ $ key ] = $ real [ $ key ] ; } $ this -> restoreLanguage ( ) ; $ this -> countryCache [ $ loadedLanguage ] = $ return ; return $ return ; }
Retrieve all country names .
26,968
public function getCountryLabel ( $ strCountry ) { $ countries = $ this -> getCountries ( ) ; return isset ( $ countries [ $ strCountry ] ) ? $ countries [ $ strCountry ] : null ; }
Retrieve the label for a given country .
26,969
private function getComponents ( ) { return array ( new Component \ Request ( ) , new Component \ Paginator ( ) , new Component \ Db ( ) , new Component \ MapperFactory ( ) , new Component \ SessionBag ( ) , new Component \ AuthManager ( ) , new Component \ AuthAttemptLimit ( ) , new Component \ ParamBag ( ) , new Component \ AppConfig ( ) , new Component \ Config ( ) , new Component \ ModuleManager ( ) , new Component \ Translator ( ) , new Component \ Response ( ) , new Component \ FlashBag ( ) , new Component \ FormAttribute ( ) , new Component \ ValidatorFactory ( ) , new Component \ WidgetFactory ( ) , new Component \ UrlBuilder ( ) , new Component \ View ( ) , new Component \ Profiler ( ) , new Component \ Cache ( ) , new Component \ CsrfProtector ( ) , new Component \ Captcha ( ) , new Component \ Dispatcher ( ) ) ; }
Returns prepared and configured framework components
26,970
private function getServices ( ) { $ container = new DependencyInjectionContainer ( ) ; $ components = $ this -> getComponents ( ) ; foreach ( $ components as $ component ) { if ( is_object ( $ component ) ) { $ container -> register ( $ component -> getName ( ) , $ component -> getInstance ( $ container , $ this -> config , $ this -> input ) ) ; } } return $ container -> getAll ( ) ; }
Returns configured and prepared core services
26,971
public function bootstrap ( ) { $ this -> tweak ( ) ; $ serviceLocator = new ServiceLocator ( ) ; $ serviceLocator -> registerArray ( $ this -> getServices ( ) ) ; define ( 'KRYSTAL' , true ) ; return $ serviceLocator ; }
Bootstrap the application . Prepare service location and module manager But do not launch the router and controllers This can be useful when you don t want to launch the application but at the same time you want to get some service from a module
26,972
public function run ( ) { if ( ! isset ( $ this -> config [ 'components' ] [ 'router' ] [ 'default' ] ) ) { throw new RuntimeException ( 'You should provide default controller for router' ) ; } $ sl = $ this -> bootstrap ( ) ; $ request = $ sl -> get ( 'request' ) ; $ dispatcher = $ sl -> get ( 'dispatcher' ) ; $ response = $ sl -> get ( 'response' ) ; if ( isset ( $ this -> config [ 'components' ] [ 'router' ] [ 'ssl' ] ) && $ this -> config [ 'components' ] [ 'router' ] [ 'ssl' ] == true ) { $ request -> sslRedirect ( ) ; } $ router = new Router ( ) ; $ route = $ router -> match ( $ request -> getURI ( ) , $ dispatcher -> getURIMap ( ) ) ; $ notFound = false ; if ( $ route !== false ) { $ content = null ; try { $ content = $ dispatcher -> render ( $ route -> getMatchedURITemplate ( ) , $ route -> getVariables ( ) ) ; } catch ( \ DomainException $ e ) { $ notFound = true ; } if ( $ content === false ) { $ notFound = true ; } } else { $ notFound = true ; } if ( $ notFound === true ) { $ default = $ this -> config [ 'components' ] [ 'router' ] [ 'default' ] ; if ( is_string ( $ default ) ) { $ notation = new RouteNotation ( ) ; $ args = $ notation -> toArgs ( $ default ) ; $ controller = $ args [ 0 ] ; $ action = $ args [ 1 ] ; $ content = $ dispatcher -> call ( $ controller , $ action ) ; } else if ( is_callable ( $ default ) ) { $ content = call_user_func ( $ default , $ sl ) ; } else { throw new LogicException ( sprintf ( 'Default route must be either callable or a string that represents default controller, not %s' , gettype ( $ default ) ) ) ; } $ response -> setStatusCode ( 404 ) ; } $ response -> send ( $ content ) ; }
Bootstraps and runs the application!
26,973
private function tweak ( ) { ini_set ( 'gd.jpeg_ignore_warning' , 1 ) ; if ( isset ( $ this -> config [ 'production' ] ) && false === $ this -> config [ 'production' ] ) { $ server = $ this -> input -> getServer ( ) ; if ( ! isset ( $ server [ 'HTTP_X_REQUESTED_WITH' ] ) ) { $ excepetionHandler = new ExceptionHandler ( ) ; $ excepetionHandler -> register ( ) ; } error_reporting ( self :: ERR_LEVEL_MAX ) ; ini_set ( 'display_errors' , 1 ) ; } else { error_reporting ( self :: ERR_LEVEL_NONE ) ; } if ( ! isset ( $ this -> config [ 'charset' ] ) ) { ini_set ( 'default_charset' , self :: DEFAULT_CHARSET ) ; mb_internal_encoding ( self :: DEFAULT_CHARSET ) ; } else { ini_set ( 'default_charset' , $ this -> config [ 'charset' ] ) ; mb_internal_encoding ( $ this -> config [ 'charset' ] ) ; } mb_substitute_character ( 'none' ) ; if ( isset ( $ this -> config [ 'locale' ] ) ) { setlocale ( LC_ALL , $ this -> config [ 'locale' ] ) ; } if ( isset ( $ this -> config [ 'timezone' ] ) ) { date_default_timezone_set ( $ this -> config [ 'timezone' ] ) ; } $ mg = new MagicQuotesFilter ( ) ; if ( $ mg -> enabled ( ) ) { $ mg -> deactivate ( ) ; $ this -> input -> setQuery ( $ mg -> filter ( $ this -> input -> getQuery ( ) ) ) ; $ this -> input -> setPost ( $ mg -> filter ( $ this -> input -> getPost ( ) ) ) ; $ this -> input -> setCookie ( $ mg -> filter ( $ this -> input -> getCookie ( ) ) ) ; $ this -> input -> setRequest ( $ mg -> filter ( $ this -> input -> getRequest ( ) ) ) ; } }
Initialization of standard library
26,974
public function sendData ( $ data ) { if ( $ this -> sendData === null ) { $ this -> sendData = $ this -> getData ( ) ; } $ data = $ this -> createSOAPEnvelope ( $ this -> prepareParameters ( $ this -> sendData ) ) ; $ headers = array ( 'Content-Type' => 'text/xml; charset=utf-8' , 'SOAPAction' => $ this -> method ) ; $ httpResponse = $ this -> httpClient -> post ( $ this -> getEndpoint ( ) , $ headers , $ data ) -> send ( ) ; return $ this -> response = new Response ( $ this , $ httpResponse -> getBody ( ) ) ; }
A helper function to send our request to the endpoint
26,975
public function buildPackageCmd ( ServiceDefinition $ serviceDefinition , $ outputDir , $ isDevFabric ) { $ args = array ( $ this -> getAzureSdkBinaryFolder ( ) . 'cspack.exe' , $ serviceDefinition -> getPath ( ) ) ; foreach ( $ serviceDefinition -> getWebRoleNames ( ) as $ roleName ) { $ args [ ] = $ this -> getRoleArgument ( $ roleName , $ serviceDefinition ) ; } foreach ( $ serviceDefinition -> getWorkerRoleNames ( ) as $ roleName ) { $ args [ ] = $ this -> getRoleArgument ( $ roleName , $ serviceDefinition ) ; } $ args [ ] = sprintf ( '/out:%s' , $ outputDir ) ; if ( $ isDevFabric ) { $ args [ ] = '/copyOnly' ; } return $ args ; }
Build Packaging command
26,976
private function isValidFormat ( $ date ) { foreach ( $ this -> formats as $ format ) { if ( date ( $ format , strtotime ( $ date ) ) == $ date ) { return true ; } } return false ; }
Validates date string against known formats
26,977
public function getCommand ( ) { return sprintf ( "put %d %d %d %d" , $ this -> _priority , $ this -> _delay , $ this -> _ttr , strlen ( $ this -> _message ) ) ; }
Get the command to send to the beanstalkd server
26,978
public function parse ( ) { $ results = [ ] ; foreach ( $ this -> output as $ account ) { if ( $ account = $ this -> parseAccount ( $ account ) ) { $ results [ ] = $ account ; } } return $ results ; }
Parses the output array into an access control list with accounts and their permission objects .
26,979
protected function parseAccount ( $ account ) { $ parts = explode ( ':' , trim ( $ account ) ) ; if ( count ( $ parts ) === 2 ) { $ account = new Account ( $ parts [ 0 ] ) ; $ acl = $ this -> parseAccessControlList ( $ parts [ 1 ] ) ; $ account -> setPermissions ( $ acl ) ; return $ account ; } return null ; }
Parses an account string with permissions into individual components .
26,980
protected function parseAccessControlList ( $ list ) { $ permissions = [ ] ; preg_match_all ( '/\((.*?)\)/' , $ list , $ matches ) ; if ( is_array ( $ matches ) && count ( $ matches ) > 0 ) { if ( array_key_exists ( 1 , $ matches ) && is_array ( $ matches [ 1 ] ) ) { foreach ( $ matches [ 1 ] as $ definition ) { $ permissions = array_merge ( $ permissions , $ this -> parseDefinitionRights ( $ definition ) ) ; } } } return $ permissions ; }
Parses an access control list string into an array of Permission objects .
26,981
protected function parseDefinitionRights ( $ definition ) { $ permissions = [ ] ; $ rights = explode ( ',' , $ definition ) ; foreach ( $ rights as $ right ) { if ( array_key_exists ( $ right , static :: $ definitions ) ) { $ permissions [ ] = new static :: $ definitions [ $ right ] ; } } return $ permissions ; }
Parses a ACE definition list into an array of permission objects .
26,982
public function countNews ( ) { $ news = 0 ; foreach ( $ this -> getDefinitionsBlockGrid ( ) as $ grid ) { $ news += $ grid -> countNews ( ) ; } return $ news ; }
Cuenta cuantos widgets hay nuevos
26,983
public function addSearchLocation ( $ location ) { if ( ! file_exists ( $ location ) ) { throw new \ InvalidArgumentException ( sprintf ( "The location path %s is not valid." , $ location ) ) ; } $ this -> searchLocations [ ] = $ location ; return $ this ; }
Add search location .
26,984
public function discover ( ) { $ classes = [ ] ; foreach ( $ this -> doFileSearch ( ) as $ file ) { $ classinfo = $ this -> parse ( $ file ) ; $ classname = $ classinfo [ 'class' ] ; $ classpath = $ file -> getRealPath ( ) ? : "$classname.php" ; if ( ! empty ( $ this -> searchMatches ) ) { foreach ( $ this -> searchMatches as $ type => $ value ) { if ( ! isset ( $ classinfo [ $ type ] ) ) { continue ; } $ instances = ! is_array ( $ classinfo [ $ type ] ) ? [ $ classinfo [ $ type ] ] : $ classinfo [ $ type ] ; $ matches = array_intersect ( $ value , $ instances ) ; if ( empty ( $ matches ) ) { continue ; } $ classes [ $ classpath ] = $ classname ; } } else { $ classes [ $ classpath ] = $ classname ; } } $ this -> requireClasses ( $ classes ) ; return $ classes ; }
Discover PHP classed based on searching criteria .
26,985
protected function doFileSearch ( ) { if ( empty ( $ this -> searchLocations ) ) { throw new \ RuntimeException ( 'No search locations have been defined.' ) ; } return ( new Finder ( ) ) -> name ( $ this -> searchPattern ) -> in ( $ this -> searchLocations ) -> depth ( $ this -> searchDepth ) -> files ( ) ; }
Perform the file search on defined search locations .
26,986
protected function requireClasses ( array $ classes ) { if ( $ this -> loadClasses ) { foreach ( $ classes as $ classpath => $ classname ) { if ( class_exists ( $ classname ) ) { continue ; } require_once "$classpath" ; } } }
Require classes that don t already exist .
26,987
protected function parse ( \ SplFileInfo $ file ) { if ( $ file -> getExtension ( ) !== 'php' ) { throw new \ InvalidArgumentException ( 'Invalid file type.' ) ; } $ info = [ ] ; $ tokens = token_get_all ( $ file -> getContents ( ) ) ; for ( $ i = 0 ; $ i < count ( $ tokens ) ; ++ $ i ) { $ token = is_array ( $ tokens [ $ i ] ) ? $ tokens [ $ i ] [ 0 ] : $ tokens [ $ i ] ; switch ( $ token ) { case T_NAMESPACE : $ info [ $ tokens [ $ i ] [ 1 ] ] = $ this -> getTokenValue ( $ tokens , [ ';' ] , $ i ) ; continue ; case T_USE : $ info [ $ tokens [ $ i ] [ 1 ] ] [ ] = $ this -> getTokenValue ( $ tokens , [ ';' , '{' , T_AS ] , $ i ) ; continue ; case T_CLASS : $ classname = $ this -> getTokenValue ( $ tokens , [ T_EXTENDS , T_IMPLEMENTS , '{' ] , $ i ) ; $ info [ $ tokens [ $ i ] [ 1 ] ] = $ this -> resolveNamespace ( $ info , $ classname ) ; continue ; case T_EXTENDS : $ classname = $ this -> getTokenValue ( $ tokens , [ T_IMPLEMENTS , '{' ] , $ i ) ; $ info [ $ tokens [ $ i ] [ 1 ] ] = $ this -> resolveNamespace ( $ info , $ classname ) ; continue ; case T_IMPLEMENTS : $ interface = $ this -> getTokenValue ( $ tokens , [ '{' ] , $ i ) ; $ info [ $ tokens [ $ i ] [ 1 ] ] [ ] = $ this -> resolveNamespace ( $ info , $ interface ) ; continue ; } } return $ info ; }
Parse PHP contents and extract the tokens .
26,988
protected function resolveNamespace ( array $ token_info , $ classname ) { if ( isset ( $ token_info [ 'use' ] ) && ! empty ( $ token_info [ 'use' ] ) && strpos ( $ classname , DIRECTORY_SEPARATOR ) === false ) { foreach ( $ token_info [ 'use' ] as $ use ) { if ( strpos ( $ use , "\\{$classname}" ) === false ) { continue ; } return $ use ; } } if ( isset ( $ token_info [ 'namespace' ] ) ) { $ classname = $ token_info [ 'namespace' ] . "\\$classname" ; } return $ classname ; }
Resolve the classname to it s fully qualified namespace .
26,989
protected function getTokenValue ( array $ tokens , array $ endings , $ iteration , $ skip_whitespace = true ) { $ value = null ; $ count = count ( $ tokens ) ; for ( $ i = $ iteration + 1 ; $ i < $ count ; ++ $ i ) { $ token = is_array ( $ tokens [ $ i ] ) ? $ tokens [ $ i ] [ 0 ] : trim ( $ tokens [ $ i ] ) ; if ( $ token === T_WHITESPACE && $ skip_whitespace ) { continue ; } if ( in_array ( $ token , $ endings ) ) { break ; } $ value .= isset ( $ tokens [ $ i ] [ 1 ] ) ? $ tokens [ $ i ] [ 1 ] : $ token ; } return $ value ; }
Get the PHP token value .
26,990
public function getReplacementsFor ( $ address ) { $ organism = $ this -> manager -> getRepository ( 'LibrinfoCRMBundle:Organism' ) -> findOneBy ( array ( 'email' => $ address ) ) ; if ( $ organism ) { if ( $ organism -> isIndividual ( ) ) { return array ( '{prenom}' => $ organism -> getFirstName ( ) , '{nom}' => $ organism -> getLastName ( ) , '{titre}' => $ organism -> getTitle ( ) , ) ; } else { return array ( '{nom}' => $ organism -> getName ( ) , ) ; } } }
Returns Contact info if LibrinfoCRMBundle is installed .
26,991
public function remove ( $ module , $ name ) { $ index = 0 ; if ( $ this -> has ( $ module , $ name , $ index ) ) { unset ( $ this -> data [ $ index ] ) ; } }
Removes by module and its associated name
26,992
public function removeAllByModule ( $ module ) { foreach ( $ this -> getIndexesByModule ( $ module ) as $ index ) { if ( isset ( $ this -> data [ $ index ] ) ) { unset ( $ this -> data [ $ index ] ) ; } } }
Removes all by associated module
26,993
private function getIndexesByModule ( $ module ) { $ indexes = array ( ) ; foreach ( $ this -> data as $ index => $ row ) { if ( isset ( $ row [ ConstProviderInterface :: CONFIG_PARAM_MODULE ] ) && $ row [ ConstProviderInterface :: CONFIG_PARAM_MODULE ] == $ module ) { array_push ( $ indexes , $ index ) ; } } return $ indexes ; }
Returns indexes by associated module
26,994
public function getAllByModule ( $ module ) { if ( ! $ this -> hasModule ( $ module ) ) { return false ; } else { $ result = array ( ) ; foreach ( $ this -> data as $ index => $ row ) { if ( isset ( $ row [ ConstProviderInterface :: CONFIG_PARAM_MODULE ] ) && $ row [ ConstProviderInterface :: CONFIG_PARAM_MODULE ] == $ module ) { $ name = $ row [ ConstProviderInterface :: CONFIG_PARAM_NAME ] ; $ value = $ row [ ConstProviderInterface :: CONFIG_PARAM_VALUE ] ; $ result [ $ name ] = $ value ; } } return $ result ; } }
Returns all data by associated module
26,995
public function get ( $ module , $ name , $ default ) { $ index = 0 ; if ( $ this -> has ( $ module , $ name , $ index ) ) { return $ this -> data [ $ index ] [ ConstProviderInterface :: CONFIG_PARAM_VALUE ] ; } else { return $ default ; } }
Returns configuration entry
26,996
public function add ( $ module , $ name , $ value ) { array_push ( $ this -> data , array ( ConstProviderInterface :: CONFIG_PARAM_MODULE => $ module , ConstProviderInterface :: CONFIG_PARAM_NAME => $ name , ConstProviderInterface :: CONFIG_PARAM_VALUE => $ value ) ) ; }
Adds configuration data
26,997
public function update ( $ module , $ name , $ value ) { foreach ( $ this -> data as $ index => $ row ) { if ( $ row [ ConstProviderInterface :: CONFIG_PARAM_MODULE ] == $ module && $ row [ ConstProviderInterface :: CONFIG_PARAM_NAME ] == $ name ) { $ this -> data [ $ index ] [ ConstProviderInterface :: CONFIG_PARAM_VALUE ] = $ value ; } } }
Updates existing pair with new value
26,998
public function hasModule ( $ module ) { foreach ( $ this -> data as $ index => $ row ) { if ( $ row [ ConstProviderInterface :: CONFIG_PARAM_MODULE ] == $ module ) { return true ; } } return false ; }
Checks whether there s at least one module in the stack with provided name
26,999
public function has ( $ module , $ name , & $ position = false ) { foreach ( $ this -> data as $ index => $ row ) { if ( $ row [ ConstProviderInterface :: CONFIG_PARAM_MODULE ] == $ module && $ row [ ConstProviderInterface :: CONFIG_PARAM_NAME ] == $ name ) { if ( $ position !== false ) { $ position = $ index ; } return true ; } } return false ; }
Checks whether module has a specific key