idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
6,900
public static function explodeText ( $ text , $ carriage = "\r" ) { $ delimiters = array ( '!' , '?' , '.' ) ; if ( $ carriage !== null ) { array_push ( $ delimiters , $ carriage ) ; } return self :: multiExplode ( $ text , $ delimiters ) ; }
Explodes a text into sentences
6,901
public static function multiExplode ( $ string , array $ delimiters , $ keepDelimiters = true ) { if ( $ keepDelimiters === true ) { foreach ( $ delimiters as & $ delimiter ) { $ delimiter = preg_quote ( $ delimiter ) ; } $ fragment = implode ( '|' , $ delimiters ) ; $ regEx = sprintf ( '@(?<=%s)@' , $ fragment ) ; ret...
Explodes a string into array supporting several delimiters
6,902
protected function mapAttributes ( array & $ data ) { $ map = $ this -> attributeMap ; $ out = [ ] ; foreach ( $ data as $ key => & $ value ) { if ( isset ( $ map [ $ key ] ) ) { $ key = $ map [ $ key ] ; } $ out [ $ key ] = $ value ; } return $ out ; }
Remap attribute keys
6,903
protected function unmapAttributes ( array & $ data ) { $ map = array_flip ( $ this -> attributeMap ) ; $ out = [ ] ; foreach ( $ data as $ key => & $ value ) { if ( isset ( $ map [ $ key ] ) ) { $ key = $ map [ $ key ] ; } $ out [ $ key ] = $ value ; } return $ out ; }
Reverse remap the attribute keys
6,904
protected function fixTypes ( array $ data , array $ typeMap , $ currencyCode ) { if ( empty ( $ typeMap ) ) { $ typeMap = $ this -> attributeTypeMap ; } if ( empty ( $ currencyCode ) ) { $ currencyCode = $ this -> _getStore ( ) -> getDefaultCurrencyCode ( ) ; } foreach ( $ typeMap as $ code => $ type ) { if ( array_ke...
Type cast array values
6,905
public function getPath ( $ id , $ file = null ) { if ( is_null ( $ file ) ) { return sprintf ( '%s/%s/' , $ this -> baseDir , $ id ) ; } else { return sprintf ( '%s/%s/%s' , $ this -> baseDir , $ id , $ file ) ; } }
Returns a path to a file in the target directory
6,906
public function upload ( $ id , array $ files ) { if ( ! empty ( $ files ) ) { $ uploader = new FileUploader ( ) ; foreach ( $ files as $ file ) { if ( ! $ uploader -> upload ( $ this -> getPath ( $ id ) , $ files ) ) { return false ; } } return true ; } return false ; }
Uploads a file into a directory by its id
6,907
public function remove ( $ id , $ filename = null ) { if ( $ filename == null ) { return FileManager :: rmdir ( $ this -> getPath ( $ id ) ) ; } else { return FileManager :: rmfile ( $ this -> getPath ( $ id , $ filename ) ) ; } }
Removes a directory by its nested id Or removes a file insider that nested directory by its nested filename
6,908
private function generate ( $ text ) { $ image = imagecreatetruecolor ( $ this -> paramBag -> getWidth ( ) , $ this -> paramBag -> getHeight ( ) ) ; $ backgroundColor = imagecolorallocate ( $ image , ( int ) ( $ this -> paramBag -> getBackgroundColor ( ) % 0x1000000 / 0x10000 ) , ( int ) ( $ this -> paramBag -> getBack...
Generates a CAPTCHA image
6,909
public function initialize ( ) { $ this -> storage -> load ( ) ; $ data = $ this -> storage -> getContent ( ) ; $ this -> arraySignature -> setData ( $ data ) ; $ this -> arrayCache -> setData ( $ data ) ; $ this -> gc ( ) ; }
Initializes the engine Should be called right after state initialization
6,910
public function save ( ) { $ data = $ this -> arrayCache -> getData ( ) ; if ( $ this -> arraySignature -> hasChanged ( $ data ) ) { if ( ! $ this -> write ( ) ) { return false ; } } return true ; }
Saves cache data if there s at least one change
6,911
public function set ( $ key , $ value , $ ttl ) { $ this -> arrayCache -> set ( $ key , $ value , $ ttl , time ( ) ) ; return $ this ; }
Stores a value to cache
6,912
private function getClassNameByPath ( $ path ) { foreach ( $ this -> map as $ key => $ value ) { if ( $ value === $ path ) { return $ key ; } } return null ; }
Returns associated class with given
6,913
public function getSummary ( ) { $ this -> stop ( ) ; if ( $ this -> start !== null ) { $ summary = $ this -> end - $ this -> start ; $ summary = round ( $ summary , 2 ) ; return $ summary ; } else { throw new LogicException ( 'Timer was not started' ) ; } }
Retrieves summary time
6,914
private function getOldAttribute ( $ name ) { if ( $ this -> hasOldAttribute ( $ name ) ) { $ collection = $ this -> getOldAttributes ( ) ; return $ collection [ $ name ] ; } else { } }
Returns old attribute value
6,915
private function appendOldAttributes ( array $ attributes ) { $ collection = $ this -> sessionBag -> get ( self :: PARAM_STORAGE_KEY ) ; $ collection = array_merge ( $ collection , $ attributes ) ; $ this -> sessionBag -> set ( self :: PARAM_STORAGE_KEY , $ collection ) ; }
Appends an attribute to collection
6,916
public function hasChanged ( $ name ) { if ( $ this -> hasOldAttribute ( $ name ) && $ this -> hasNewAttribute ( $ name ) ) { return $ this -> getOldAttribute ( $ name ) != $ this -> getNewAttribute ( $ name ) ; } else { } }
Determines whether attribute has been changed or not
6,917
public function getChangedAttributes ( ) { $ output = array ( ) ; foreach ( $ this -> attributes as $ name => $ value ) { if ( $ this -> hasChanged ( $ name ) ) { $ output [ $ name ] = $ value ; } } return $ output ; }
Returns a collection of changed attributes
6,918
public function getUnchangedAttributes ( ) { $ output = array ( ) ; foreach ( $ this -> attributes as $ name => $ value ) { if ( ! $ this -> hasChanged ( $ name ) ) { $ output [ $ name ] = $ value ; } } return $ output ; }
Returns a collection of unchanged attributes
6,919
public function execRaw ( $ command , $ service = null , $ options = [ ] , $ quiet = false ) { $ container_id = $ this -> askForServiceContainerId ( $ service ) ; return $ this -> runCommandInContainer ( $ container_id , $ command , $ options , $ quiet ) ; }
Execute raw command .
6,920
public function rebuildDocker ( ) { $ this -> _remove ( $ this -> getInstallPath ( ) . '/services' ) ; $ this -> buildDockerCompose ( ) ; if ( $ this -> hasDockerSync ( ) ) { $ this -> buildDockerComposeDev ( ) ; } return $ this ; }
Rebuild Docker configurations .
6,921
public function hasTraefik ( ) { $ network = ProjectX :: getProjectConfig ( ) -> getNetwork ( ) ; return isset ( $ network [ 'proxy' ] ) && $ network [ 'proxy' ] ? $ network [ 'proxy' ] : false ; }
Using the traefik network proxy .
6,922
public function isEngineRunning ( ) { foreach ( array_keys ( $ this -> getServices ( ) ) as $ name ) { $ container = $ this -> getServiceContainerId ( $ name ) ; if ( ! $ this -> isContainerRunning ( $ container ) ) { return false ; } } return true ; }
Determine if the environment engine is running .
6,923
public function isDockerSyncRunning ( ) { $ container = $ this -> getDockerSyncContainer ( ) ; return $ this -> hasDockerContainer ( $ container ) && $ this -> isContainerRunning ( $ container ) ; }
Determine if docker sync running .
6,924
public function requiredPorts ( ) { $ ports = [ ] ; foreach ( $ this -> getServiceInstances ( ) as $ info ) { if ( ! isset ( $ info [ 'instance' ] ) ) { continue ; } $ instance = $ info [ 'instance' ] ; if ( $ instance instanceof ServiceInterface ) { $ ports = array_merge ( $ ports , $ instance -> getHostPorts ( ) ) ; ...
Get required ports based on services .
6,925
public function copyFileToService ( $ from , $ destination , $ service ) { if ( ! file_exists ( $ from ) ) { throw new EngineRuntimeException ( 'The file path does not exist.' ) ; } $ container = $ this -> getServiceContainerId ( $ service ) ; return $ this -> _exec ( "docker cp {$from} {$container}:{$destination}" ) ;...
Copy file to docker service .
6,926
public function getFileMimeType ( $ filename , $ service ) { $ binary = '/usr/bin/file' ; $ mime_type = $ this -> exec ( "if [ -e {$binary} ]; then {$binary} -b --mime-type {$filename}; fi" , $ service , [ ] , true ) ; if ( empty ( $ mime_type ) ) { throw new \ Exception ( sprintf ( 'No mime type was captured for %s.' ...
Get the file mime type .
6,927
protected function buildDockerComposeServices ( ) { $ this -> say ( 'Docker compose build process is running...' ) ; $ this -> taskDockerComposeBuild ( ) -> printOutput ( false ) -> pull ( ) -> run ( ) ; return $ this ; }
Build docker composer services .
6,928
protected function askForServiceContainerId ( $ service = null ) { if ( ! isset ( $ service ) ) { $ service = $ this -> askForServiceName ( ) ; } $ container_id = $ this -> getServiceContainerId ( $ service ) ; if ( $ container_id === false ) { throw new EngineRuntimeException ( sprintf ( 'Unable to obtain the containe...
Ask for the service container identifier .
6,929
protected function startTraefik ( ) { if ( $ this -> hasTraefik ( ) ) { $ this -> createTraefikNetworkProxy ( ) ; if ( ! $ this -> isTraefikRunning ( ) ) { $ container = self :: TRAEFIK_CONTAINER_NAME ; if ( $ this -> hasDockerContainer ( $ container ) ) { $ result = $ this -> taskDockerStart ( $ container ) -> run ( )...
Start the traefik container if not already running .
6,930
protected function stopTraefik ( ) { if ( $ this -> hasTraefik ( ) ) { $ container = self :: TRAEFIK_CONTAINER_NAME ; if ( $ this -> isTraefikRunning ( ) && $ this -> hasDockerContainer ( $ container ) ) { $ this -> say ( sprintf ( 'Container "%s" has been stopped.' , $ container ) ) ; $ this -> taskDockerStop ( $ cont...
Stop traefik project - x container .
6,931
protected function createTraefikNetworkProxy ( ) { $ network = self :: TRAEFIK_NETWORK ; if ( ! $ this -> hasDockerNetwork ( $ network ) ) { $ this -> say ( "Creating '{$network}' network..." ) ; $ this -> taskExec ( "docker network create {$network}" ) -> printOutput ( false ) -> run ( ) ; } return $ this ; }
Create the traefik network proxy .
6,932
protected function hasDockerContainer ( $ name ) { $ result = $ this -> runSilentCommand ( $ this -> taskExec ( "docker ps --filter='name={$name}' -q" ) ) ; $ output = $ result -> getMessage ( ) ; return isset ( $ output ) && ! empty ( $ output ) ; }
Has the docker container been defined .
6,933
protected function isContainerRunning ( $ container ) { $ result = $ this -> runSilentCommand ( $ this -> taskExec ( "docker inspect -f {{.State.Running}} {$container}" ) ) ; return $ result -> getExitCode ( ) === Resultdata :: EXITCODE_OK && $ result -> getMessage ( ) == 'true' ; }
Determine if docker container is running .
6,934
protected function generateDockerCompose ( $ dev = false ) { $ docker_compose = new DockerComposeConfig ( ) ; $ docker_compose -> setVersion ( static :: DOCKER_VERSION ) ; $ has_proxy = $ this -> hasTraefik ( ) ? true : false ; foreach ( $ this -> getServices ( ) as $ name => $ info ) { if ( ! isset ( $ info [ 'type' ]...
Generate docker - compose object .
6,935
protected function copyDockerServiceFiles ( ) { $ root = ProjectX :: projectRoot ( ) . "/docker/services" ; $ configs = $ this -> getProjectServiceConfigs ( ) ; $ project_type = $ this -> getProjectType ( ) ; foreach ( $ this -> getServices ( ) as $ name => $ info ) { if ( ! isset ( $ info [ 'type' ] ) ) { continue ; }...
Copy docker service template files .
6,936
protected function showRequiredPortsTable ( array $ ports , $ host = '127.0.0.1' ) { $ status = $ this -> getPortStatus ( $ host , $ ports ) ; if ( ! empty ( $ status ) ) { $ has_warning = isset ( $ status [ 'state' ] [ 'warning' ] ) && $ status [ 'state' ] [ 'warning' ] !== 0 ? true : false ; if ( $ has_warning ) { $ ...
Show required ports table .
6,937
protected function buildPortStatusRows ( array $ status ) { $ rows = [ ] ; foreach ( $ status [ 'ports' ] as $ port => $ value ) { $ row = [ $ port , $ value [ 'status' ] , ] ; $ rows [ ] = $ row ; } $ warnings = $ status [ 'state' ] [ 'warning' ] ; $ rows [ ] = new TableSeparator ( ) ; $ rows [ ] = [ new TableCell ( s...
Build port status rows .
6,938
protected function getDockerComposeFiles ( ) { $ files = [ 'docker-compose.yml' , ] ; $ root = ProjectX :: projectRoot ( ) ; $ path = "{$root}/docker-compose-dev.yml" ; if ( $ this -> hasDockerSync ( ) && $ this -> useDockerSync && file_exists ( $ path ) ) { $ files [ ] = $ path ; } return $ files ; }
Get docker compose files to load .
6,939
protected function runDockerSyncDownCollection ( ) { $ this -> collectionBuilder ( ) -> addTask ( $ this -> taskDockerSyncStop ( ) ) -> completion ( $ this -> taskDockerSyncClean ( ) ) -> run ( ) ; }
Shutdown docker - sync collection .
6,940
protected function runCommandInContainer ( $ container_id , $ command , array $ options = [ ] , $ quiet = false , $ interactive = false ) { if ( ! isset ( $ container_id ) || ! isset ( $ command ) ) { return false ; } $ docker_execute = $ this -> taskDockerExec ( $ container_id ) ; if ( $ quiet ) { $ docker_execute -> ...
Run a command in docker container .
6,941
protected function getServiceContainerId ( $ container ) { if ( ! isset ( $ container ) ) { return false ; } $ task = $ this -> taskDockerComposePs ( ) ; $ result = $ this -> runSilentCommand ( $ task -> setService ( $ container ) -> quiet ( ) ) ; if ( $ result -> getExitCode ( ) !== ResultData :: EXITCODE_OK ) { retur...
Get service container identifier .
6,942
protected function setDockerSyncNameInEnv ( ) { $ project_root = ProjectX :: projectRoot ( ) ; $ project_name = ProjectX :: getProjectMachineName ( ) ; $ sync_name = uniqid ( "$project_name-" , false ) ; $ this -> taskWriteToFile ( "{$project_root}/.env" ) -> append ( ) -> appendUnlessMatches ( '/SYNC_NAME=\w+/' , "SYN...
Set docker - sync name in environment file ; if not already set .
6,943
protected function setHostIPAddressInEnv ( ) { $ host_ip = ProjectX :: clientHostIP ( ) ; $ project_root = ProjectX :: projectRoot ( ) ; $ this -> taskWriteToFile ( "$project_root/.env" ) -> append ( ) -> regexReplace ( '/HOST_IP_ADDRESS=.*/' , "HOST_IP_ADDRESS={$host_ip}" ) -> appendUnlessMatches ( '/HOST_IP_ADDRESS=....
Set host IP address in environment file .
6,944
public function getStoreData ( ) { if ( ! isset ( $ this -> fileDataCache ) || empty ( $ this -> fileDataCache ) ) { $ data = [ ] ; if ( $ this -> hasStoreData ( ) ) { $ filename = static :: FILE_NAME ; $ contents = file_get_contents ( "{$this->filepath}/{$filename}" ) ; if ( ! empty ( $ contents ) && $ contents !== fa...
Get YAML store contents .
6,945
public function clearCache ( ) { if ( isset ( $ this -> fileDataCache ) && ! empty ( $ this -> fileDataCache ) ) { $ this -> fileDataCache = null ; } return $ this ; }
Clear the data store cache .
6,946
public function save ( ) { $ contents = array_filter ( $ this -> contents ) ; if ( empty ( $ contents ) ) { return ; } if ( ! file_exists ( $ this -> filepath ) ) { mkdir ( $ this -> filepath ) ; } return ( new YamlFilesystem ( $ contents , $ this -> filepath ) ) -> save ( static :: FILE_NAME ) ; }
Save the YAML store .
6,947
protected function findFilePath ( ) { $ filename = static :: FILE_NAME ; foreach ( $ this -> defaultLocations ( ) as $ location ) { if ( file_exists ( "{$location}/$filename" ) ) { return $ location ; } } return $ this -> defaultFilePath ( ) ; }
Find file path .
6,948
public function updateCMSFields ( FieldList $ fields ) { $ fields -> addFieldToTab ( 'Root' , TabSet :: create ( 'Newssettings' , _t ( 'NewsSiteConfigExtension.NEWSCOMMENTS' , 'News settings' ) ) ) ; if ( ( $ this -> owner -> AllowAuthors && $ this -> owner -> canEdit ( Member :: currentUser ( ) ) ) || Member :: curren...
Update the SiteConfig with the news - settings . The tabs are pushed into arrays because it works better than adding them one by one .
6,949
protected function NewsTab ( ) { return Tab :: create ( 'News' , _t ( 'NewsSiteConfigExtension.NEWS' , 'News' ) , CheckboxField :: create ( 'UseAbstract' , _t ( 'NewsSiteConfigExtension.ABSTRACT' , 'Use abstract/summary' ) ) , CheckboxField :: create ( 'TweetOnPost' , _t ( 'NewsSiteConfigExtension.TWEETPOST' , 'Tweet a...
Setup the tabs for the user All return a Tab .
6,950
protected function URLMappingTab ( ) { return Tab :: create ( 'URL Mapping' , _t ( 'NewsSiteConfigExtension.MAPPING' , 'URL Mapping' ) , LiteralField :: create ( 'mappinghelp' , _t ( 'NewsSiteConfigExtension.MAPPINGHELP' , 'Set the URL Parameters to handle things to your wishing, e.g. /news/newsitem instead of /news/sh...
Setup the Admin - only tabs .
6,951
public function onBeforeWrite ( ) { $ maps = array ( 'TagAction' , 'TagsAction' , 'ShowAction' , 'AuthorAction' , 'ArchiveAction' , ) ; foreach ( $ maps as $ map ) { if ( $ this -> owner -> $ map ) { $ this -> owner -> $ map = singleton ( 'SiteTree' ) -> generateURLSegment ( $ this -> owner -> $ map ) ; } } $ newsFolde...
Make sure the chosen action by the user is safe for usage .
6,952
private function createHttpRequest ( $ content ) { $ httpRequest = new \ Zend \ Http \ Request ( ) ; $ httpRequest -> setUri ( $ this -> _endPoint ) ; $ httpRequest -> setMethod ( \ Zend \ Http \ Request :: METHOD_POST ) ; $ httpRequest -> setContent ( $ content ) ; $ headers = $ httpRequest -> getHeaders ( ) ; if ( ! ...
Creates a new HTTP POST request with the appropriate content headers and such which can then be used to send JSON - RPC requests .
6,953
private function performHttpRequest ( $ httpRequest , $ ensureSuccess = true ) { $ httpResponse = null ; try { $ httpResponse = $ this -> _httpClient -> dispatch ( $ httpRequest ) ; } catch ( \ Exception $ e ) { if ( $ ensureSuccess ) throw new ClientException ( $ e -> getMessage ( ) , $ e -> getCode ( ) ) ; } if ( $ e...
Performs the specified HTTP request and returns the HTTP response
6,954
public function sendMessage ( Message $ message , array $ to = [ ] , array $ cc = [ ] , array $ bcc = [ ] ) { $ this -> swift -> send ( $ this -> adaptMessage ( $ message , $ to , $ cc , $ bcc ) ) ; }
Send the given message .
6,955
private function adaptMessage ( Message $ message , array $ to , array $ cc , array $ bcc ) : Swift_Message { $ swiftMessage = new Swift_Message ( $ message -> subject ( ) , null , $ message -> content ( ) -> mimeType ( ) ) ; $ cids = $ this -> moveAttachments ( $ message , $ swiftMessage ) ; $ swiftMessage -> setBody ...
Adapt the given message to a Swift message .
6,956
private function adaptAddresses ( array $ addresses ) : array { $ adapted = [ ] ; foreach ( $ addresses as $ address ) { if ( $ address -> name ( ) !== null ) { $ adapted [ $ address -> email ( ) ] = $ address -> name ( ) ; } else { $ adapted [ ] = $ address -> email ( ) ; } } return $ adapted ; }
Adapt the given e - mail addresses to a format suitable for Swift Mailer .
6,957
private function moveAttachments ( Message $ from , Swift_Message $ to ) : array { foreach ( $ from -> content ( ) -> attachments ( ) as $ path ) { $ to -> attach ( Swift_Attachment :: fromPath ( $ path ) ) ; } $ cids = [ ] ; foreach ( $ from -> content ( ) -> embeddedAttachments ( ) as $ id => $ path ) { $ cids [ $ id...
Move attachments from the given message to the given Swift message .
6,958
public function isValidDataArray ( array $ data ) { if ( count ( $ data ) === 0 ) { return true ; } $ result = true ; foreach ( $ data as $ object ) { if ( ! is_array ( $ object ) ) { $ result = false ; break ; } if ( count ( $ object ) < 2 ) { $ result = false ; break ; } $ name = current ( $ object ) ; if ( empty ( $...
Checks if the data for a given item is correct
6,959
public function hasRequiredKeys ( array $ input ) { $ control = array_intersect ( $ this -> required , array_keys ( $ input ) ) ; if ( $ this -> required !== $ control ) { return $ this -> required ; } return true ; }
Return TRUE when the input has the required keys othewise it will return an arrays containing the list of required keys
6,960
public function getAll ( ) { $ instances = array ( ) ; $ builder = new InstanceBuilder ( ) ; foreach ( $ this -> data as $ className => $ args ) { if ( class_exists ( $ className ) ) { $ instance = $ builder -> build ( $ className , $ args ) ; array_push ( $ instances , $ instance ) ; } } return $ instances ; }
Returns all instances that are available
6,961
public static function fromString ( string $ emailAddress ) : self { if ( ! preg_match ( '/^([^><]+?)\s*(?:<([^><]+)>)?$/' , $ emailAddress , $ matches ) ) { throw new InvalidArgumentException ( sprintf ( '"%s" is not a valid e-mail address.' , $ emailAddress ) ) ; } return isset ( $ matches [ 2 ] ) ? new static ( $ ma...
Create a new e - mail address by parsing the given string .
6,962
public function getAllOptions ( $ filteringOption = null ) { if ( is_null ( $ filteringOption ) ) { return array_values ( $ this -> container ) ; } else { $ result = array ( ) ; foreach ( $ this -> container as $ key => $ options ) { if ( isset ( $ options [ $ filteringOption ] ) ) { $ result [ ] = $ options [ $ filter...
Return options from the collection
6,963
public function getWithOption ( $ key , $ option , $ default = false ) { if ( $ this -> hasOption ( $ key , $ option ) ) { return $ this -> container [ $ key ] [ $ option ] ; } else { return $ default ; } }
Returns key s option
6,964
public function hasOption ( $ key , $ option ) { return isset ( $ this -> container [ $ key ] ) && array_key_exists ( $ option , $ this -> container [ $ key ] ) ; }
Checks whether provided key has an option
6,965
public function addWithOption ( $ key , $ option , $ value , $ append = true ) { if ( ! isset ( $ this -> container [ $ key ] ) ) { $ this -> container [ $ key ] = array ( $ option => $ value ) ; } else { if ( $ append === true ) { $ this -> container [ $ key ] [ $ option ] = $ value ; } } return $ this ; }
Adds key data with option and its value
6,966
public function updateWithOption ( $ key , $ option , $ value ) { if ( $ this -> hasOption ( $ key , $ option ) ) { $ this -> container [ $ key ] [ $ option ] = $ value ; } return $ this ; }
Updates an option by its associated key
6,967
public function removeOptionByKey ( $ key , $ option ) { if ( $ this -> hasOption ( $ key , $ option ) ) { unset ( $ this -> container [ $ key ] [ $ option ] ) ; } return $ this ; }
Removes an option by its associated key
6,968
public function removeKey ( $ key ) { if ( $ this -> hasKey ( $ key ) ) { unset ( $ this -> container [ $ key ] ) ; return true ; } else { return false ; } }
Removes all data by its associated key
6,969
public function renderSection ( $ name ) { switch ( $ name ) { case '{summary}' : return $ this -> renderSummary ( ) ; case '{items}' : return $ this -> renderItems ( ) ; case '{pager}' : return $ this -> renderPager ( ) ; case '{sorter}' : return $ this -> renderSorter ( ) ; case '{actions}' : return $ this -> renderA...
Renders a section of the specified name . If the named section is not supported false will be returned .
6,970
public function renderActions ( ) { $ str = '' ; if ( count ( $ this -> buttons ) ) { foreach ( $ this -> buttons as $ button ) { $ str .= Html :: a ( $ button [ 'text' ] , $ button [ 'url' ] , $ button [ 'options' ] ) ; } } if ( $ str ) return "<div class=\"table-actions\">\n <label class=\"pull...
Renders the actions for the selected rows .
6,971
public function getConstraints ( $ version ) { if ( ! isset ( $ this -> constraints [ $ version ] ) ) { $ this -> constraints [ $ version ] = $ this -> createConstraints ( $ version ) ; } return $ this -> constraints [ $ version ] ; }
Returns the constraints associated with a given JSON Schema version .
6,972
public function getConstraintsForType ( $ version , $ type ) { $ cache = & $ this -> constraintsForTypeCache [ $ version . $ type ] ; if ( $ cache === null ) { $ cache = [ ] ; foreach ( $ this -> getConstraints ( $ version ) as $ constraint ) { if ( $ constraint -> supports ( $ type ) ) { $ cache [ ] = $ constraint ; }...
Returns the constraints associated with a given JSON Schema version supporting a given primitive type .
6,973
public function hasKeyword ( $ version , $ keyword ) { $ cache = & $ this -> keywordsCache [ $ version ] ; if ( $ cache === null ) { $ cache = [ ] ; foreach ( $ this -> getConstraints ( $ version ) as $ constraint ) { foreach ( $ constraint -> keywords ( ) as $ constraintKeyword ) { $ cache [ $ constraintKeyword ] = tr...
Returns whether a keyword is supported in a given JSON Schema version .
6,974
protected function createConstraints ( $ version ) { switch ( $ version ) { case self :: VERSION_CURRENT : case self :: VERSION_DRAFT_4 : return $ this -> createBuiltInConstraints ( array_merge ( self :: $ commonConstraints , self :: $ draft4Constraints ) ) ; default : throw new UnsupportedVersionException ( "Schema ve...
Loads the constraints associated with a given JSON Schema version .
6,975
public static function getLastSQL ( $ type = self :: SQL_RETURN_TYPE_STRING , $ withEagerLoading = false ) { $ queries = DB :: getQueryLog ( ) ; $ ret = [ ' -------- last queries --------' ] ; if ( $ withEagerLoading ) { foreach ( $ queries as $ query ) { if ( self :: SQL_RETURN_TYPE_STRING == $ type ) { $ queryString ...
return the SQL statement just have been executed .
6,976
protected function addStage ( string $ name , string $ message , callable $ callback ) : void { $ this -> stages [ $ name ] = [ "message" => $ message , "callback" => $ callback ] ; }
Add a stage .
6,977
protected function loadData ( string $ name ) { if ( isset ( $ this -> data [ $ name ] ) ) return $ this -> data [ $ name ] ; else return null ; }
Load saved data .
6,978
public function setMessage ( \ TelegramBot \ Api \ Types \ Message $ message ) : void { $ this -> message = $ message ; $ this -> chatId = $ this -> message -> getChat ( ) -> getId ( ) ; $ this -> userId = $ this -> message -> getFrom ( ) -> getId ( ) ; }
Sets the message that last affected the conversation . Done by the framework .
6,979
private function boot ( ) { $ this -> init = true ; $ configsObjectsDeft = $ iconsDefinition = [ ] ; $ this -> linkGeneratorItemsForClass = [ ] ; foreach ( $ this -> linkGeneratorItems as $ linkGeneratorItem ) { $ configObjects = $ linkGeneratorItem -> getConfigObjects ( ) ; foreach ( $ configObjects as $ key => $ conf...
Genera la configuracion de los objetos agreagados
6,980
protected function renderDefault ( $ entity , $ entityConfig , $ type = self :: TYPE_LINK_DEFAULT , array $ parameters = array ( ) ) { $ route = $ entityConfig [ 'route' ] ; $ routeParameters = $ entityConfig [ 'routeParameters' ] ; $ labelMethod = $ entityConfig [ 'labelMethod' ] ; if ( $ labelMethod !== null ) { $ la...
Metodo que renderiza el link por defecto
6,981
public function buildUrl ( $ entity , $ entityConfig ) { $ route = $ entityConfig [ 'route' ] ; $ routeParameters = $ entityConfig [ 'routeParameters' ] ; $ href = '' ; if ( $ route != null ) { $ href = $ this -> generateUrl ( $ route , array_merge ( array ( 'id' => $ entity -> getId ( ) ) , $ routeParameters ) ) ; } r...
Genera la url
6,982
protected function getEntityConf ( $ entity ) { $ entityClass = get_class ( $ entity ) ; if ( $ this -> init === false ) { $ this -> boot ( ) ; } if ( preg_match ( '/' . \ Doctrine \ Common \ Persistence \ Proxy :: MARKER . '/' , $ entityClass ) ) { $ entityClass = \ Doctrine \ Common \ Util \ ClassUtils :: getRealClas...
Retorna la configuracion de una entidad u objeto
6,983
private function generateFromConfig ( $ entity , array $ entityConfig , $ type , $ parameters = array ( ) ) { $ method = $ entityConfig [ 'type' ] [ $ type ] [ 'method' ] ; if ( $ method === "renderDefault" ) { return call_user_func_array ( array ( $ this , $ method ) , array ( $ entity , $ entityConfig [ 'type' ] [ $ ...
Genera un link a partir de la configuracion de ese objeto
6,984
public function generate ( $ entity , $ type = self :: TYPE_LINK_DEFAULT , $ parameters = array ( ) ) { if ( $ type === null ) { $ type = self :: TYPE_LINK_DEFAULT ; } $ entityConfig = $ this -> getEntityConf ( $ entity ) ; $ link = '' ; if ( $ entityConfig ) { $ link = $ this -> generateFromConfig ( $ entity , $ entit...
Genera el link del objeto
6,985
public function getConfigFromEntity ( $ entity ) { $ parameters = array ( ) ; $ parameters [ '_onlyConf' ] = true ; return $ this -> generate ( $ entity , null , $ parameters ) ; }
Retornal la configuracion de una entidad
6,986
final protected function parseData ( array $ data , $ parentId = 0 ) { $ result = array ( ) ; foreach ( $ data as $ subArray ) { $ nested = array ( ) ; if ( isset ( $ subArray [ $ this -> childrenKey ] ) ) { $ nested = $ this -> parseData ( $ subArray [ $ this -> childrenKey ] , $ subArray [ RelationBuilder :: TREE_PAR...
Parses nested array with children
6,987
public function hasKey ( $ target ) { foreach ( $ this -> collection as $ group => $ hashMap ) { if ( array_key_exists ( $ target , $ hashMap ) ) { return true ; } } return false ; }
Checks whether key in collection exist
6,988
public function findByKey ( $ target , $ default = '' ) { foreach ( $ this -> collection as $ group => $ hashMap ) { if ( array_key_exists ( $ target , $ hashMap ) ) { return $ hashMap [ $ target ] ; } } return $ default ; }
Find a value by its associated key
6,989
function formatXml ( SimpleXMLElement $ simpleXMLElement ) { $ xmlDocument = new DOMDocument ( '1.0' ) ; $ xmlDocument -> preserveWhiteSpace = false ; $ xmlDocument -> formatOutput = true ; $ xmlDocument -> loadXML ( $ simpleXMLElement -> asXML ( ) ) ; return $ xmlDocument -> saveXML ( ) ; }
Formatea el xml a formato pretty manteniendo los saltos de linea
6,990
public function decrement ( $ key , $ step ) { $ value = $ this -> getValueByKey ( $ key , false ) ; $ this -> alter ( $ key , $ value - $ step ) ; }
Decrements a value
6,991
public function getAsPair ( ) { $ result = array ( ) ; foreach ( $ this -> data as $ key => $ options ) { $ result [ $ key ] = $ options [ self :: CACHE_PARAM_VALUE ] ; } return $ result ; }
Returns cache data as key = > value pair
6,992
public function isExpired ( $ key , $ time ) { return $ this -> getCreatedTime ( $ key ) + $ this -> getTtl ( $ key ) < $ time ; }
Checks whether cache key is expired
6,993
public function set ( $ key , $ value , $ ttl , $ time ) { $ this -> data [ $ key ] = array ( self :: CACHE_PARAM_VALUE => $ value , self :: CACHE_PARAM_CREATED => $ time , self :: CACHE_PARAM_TTL => $ ttl ) ; return $ this ; }
Sets the cache data
6,994
public function remove ( $ key ) { if ( $ this -> has ( $ key ) ) { unset ( $ this -> data [ $ key ] ) ; return true ; } else { return false ; } }
Removes a key
6,995
private function alter ( $ key , $ value ) { if ( $ this -> has ( $ key ) ) { $ this -> data [ $ key ] [ self :: CACHE_PARAM_VALUE ] = $ value ; } }
Alters key s value
6,996
private function get ( $ key , $ value , $ default ) { if ( $ this -> has ( $ key ) ) { return $ this -> data [ $ key ] [ $ value ] ; } else { return $ default ; } }
Returns data by associated key
6,997
public function getCellIds ( $ latitude , $ longitude , $ width = 9 ) { $ s2latLng = S2LatLng :: fromDegrees ( $ latitude , $ longitude ) ; $ cellId = S2CellId :: fromLatLng ( $ s2latLng ) -> parent ( 15 ) ; $ size = 1 * ( 2 ** ( S2CellId :: MAX_LEVEL - $ cellId -> level ( ) ) ) ; $ index = 0 ; $ jindex = 0 ; $ face = ...
Returns a list of cell ids for latitue and longitude .
6,998
protected function _convert ( $ css ) { $ css = $ this -> _clean ( $ css ) ; $ css = explode ( '}' , $ css ) ; $ css = array_filter ( $ css , 'strlen' ) ; foreach ( $ css as $ key => $ val ) { $ css [ $ key ] = explode ( '{' , $ val ) ; } foreach ( $ css as $ key => $ css_block ) { $ css [ $ key ] = $ this -> _create_c...
Convert inline css to PHP array
6,999
protected function validateTaskResult ( Result $ result ) { if ( $ result -> getExitCode ( ) !== Result :: EXITCODE_OK ) { throw new TaskResultRuntimeException ( $ result ) ; } return $ result ; }
Validate task result .