idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
10,800
public function normalize ( $ obj ) { $ properties = $ this -> getClassProperties ( get_class ( $ obj ) ) ; $ data = [ ] ; foreach ( $ properties as $ name => $ prop ) { if ( isset ( $ prop [ 'getter' ] ) ) { $ getter = $ prop [ 'getter' ] ; $ value = $ obj -> $ getter ( ) ; } else { $ key = $ prop [ 'name' ] ; $ value = $ obj -> $ key ; } if ( isset ( $ prop [ 'type' ] ) ) { if ( $ prop [ 'type' ] === 'array' ) { $ value = array_map ( function ( $ elem ) use ( $ prop ) { return $ this -> normalize ( $ elem ) ; } , $ value ) ; } else { $ value = $ this -> normalize ( $ value ) ; } } if ( isset ( $ prop [ 'serializeName' ] ) ) { $ name = $ prop [ 'serializeName' ] ; } $ data [ $ name ] = $ value ; } return $ data ; }
Normalizes the object into an array of scalars|arrays .
10,801
private function getClassProperties ( $ class ) { $ properties = $ this -> getCache ( ) -> get ( '_PHX.serialze_properties.' . $ class ) ; if ( ! isset ( $ properties ) ) { $ classResolver = $ this -> getClassResolver ( ) ; $ properties = $ this -> getReflectionProperties ( $ class ) ; foreach ( $ this -> getAnnotations ( ) -> get ( $ class ) as $ annotation ) { if ( $ annotation instanceof IsA ) { $ properties [ $ this -> getAnnotationProperty ( $ annotation ) ] [ 'type' ] = $ classResolver -> resolve ( $ annotation -> class , $ annotation -> getDeclaringClass ( ) ) ; } elseif ( $ annotation instanceof IsArray && is_scalar ( $ annotation -> element ) ) { $ name = $ this -> getAnnotationProperty ( $ annotation ) ; $ properties [ $ name ] [ 'type' ] = 'array' ; $ properties [ $ name ] [ 'element' ] = $ classResolver -> resolve ( $ annotation -> element , $ annotation -> getDeclaringClass ( ) ) ; } elseif ( $ annotation instanceof SerializeName ) { $ properties [ $ this -> getAnnotationProperty ( $ annotation ) ] [ 'serializeName' ] = $ annotation -> value ; } } $ this -> getCache ( ) -> save ( '_PHX.serialze_properties.' . $ class , $ properties ) ; } return $ properties ; }
gets class properties metadata
10,802
public function getSiteFilterQuery ( $ targetTableAlias ) { $ parent = $ this -> getParent ( ) ; if ( $ parent and $ parentId = $ parent -> getId ( ) ) { return $ targetTableAlias . '.site_id = ' . $ parentId ; } elseif ( $ id = $ this -> getId ( ) ) { return $ targetTableAlias . '.site_id = ' . $ id ; } return '' ; }
Get filter query
10,803
public function sumOfferCount ( ) { $ count = $ this -> getOfferCount ( ) ; if ( $ this -> getParent ( ) ) { $ count += $ this -> getParent ( ) -> getOfferCount ( ) ; } if ( $ this -> getLinkedSites ( ) -> count ( ) ) { foreach ( $ this -> getLinkedSites ( ) as $ linked ) { $ count += $ linked -> getOfferCount ( ) ; } } if ( $ this -> getSubDomains ( ) -> count ( ) ) { foreach ( $ this -> getSubDomains ( ) as $ linked ) { $ count += $ linked -> getOfferCount ( ) ; } } return $ count ; }
Get sum of all offers
10,804
public function afterScript ( Buffer $ buffer ) { $ buffer -> write ( sprintf ( '$z->pop(\'%s\');' , $ this -> key ) ) ; $ buffer -> write ( sprintf ( '$z->pop(\'%s\');' , $ this -> value ) ) ; $ buffer -> indent ( - 1 ) ; $ buffer -> writeln ( '}' ) ; }
Allows the annotation to modify the buffer after the script is compiled .
10,805
protected function _timeToMongoDate ( $ time ) { if ( ! is_numeric ( $ time ) ) { $ time = strtotime ( $ time ) ; if ( ! $ time ) { $ time = time ( ) ; } } return new \ MongoDate ( $ time ) ; }
Convert time in different formats to mongo date
10,806
protected function processLogs ( $ logs ) { $ logCollection = \ Yii :: app ( ) -> { $ this -> serviceName } -> getCollection ( $ this -> collectionName ) ; foreach ( $ logs as $ log ) { $ logCollection -> createDocument ( array ( 'level' => $ log [ 1 ] , 'category' => $ log [ 2 ] , 'logtime' => $ this -> _timeToMongoDate ( $ log [ 3 ] ) , 'message' => $ log [ 0 ] , 'requestUri' => isset ( $ _SERVER [ 'REQUEST_URI' ] ) ? $ _SERVER [ 'REQUEST_URI' ] : null , 'userAgent' => isset ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) ? $ _SERVER [ 'HTTP_USER_AGENT' ] : null , ) ) -> save ( ) ; } }
Write log messages
10,807
public function isSingular ( Pluralizer $ pluralizer = null ) { $ pluralizer = $ pluralizer ? : new EnglishPluralizer ( ) ; return $ pluralizer -> isSingular ( $ this -> string ) ; }
Check if a string is singular form .
10,808
public function isPlural ( Pluralizer $ pluralizer = null ) { $ pluralizer = $ pluralizer ? : new EnglishPluralizer ( ) ; return $ pluralizer -> isPlural ( $ this -> string ) ; }
Check if a string is plural form .
10,809
protected function initRuntimeVars ( Dwoo_ITemplate $ tpl ) { $ this -> runtimePlugins = array ( ) ; $ this -> scope = & $ this -> data ; $ this -> scopeTree = array ( ) ; $ this -> stack = array ( ) ; $ this -> curBlock = null ; $ this -> buffer = '' ; }
re - initializes the runtime variables before each template run
10,810
public function addPlugin ( $ name , $ callback , $ compilable = false ) { $ compilable = $ compilable ? self :: COMPILABLE_PLUGIN : 0 ; if ( is_array ( $ callback ) ) { if ( is_subclass_of ( is_object ( $ callback [ 0 ] ) ? get_class ( $ callback [ 0 ] ) : $ callback [ 0 ] , 'Dwoo_Block_Plugin' ) ) { $ this -> plugins [ $ name ] = array ( 'type' => self :: BLOCK_PLUGIN | $ compilable , 'callback' => $ callback , 'class' => ( is_object ( $ callback [ 0 ] ) ? get_class ( $ callback [ 0 ] ) : $ callback [ 0 ] ) ) ; } else { $ this -> plugins [ $ name ] = array ( 'type' => self :: CLASS_PLUGIN | $ compilable , 'callback' => $ callback , 'class' => ( is_object ( $ callback [ 0 ] ) ? get_class ( $ callback [ 0 ] ) : $ callback [ 0 ] ) , 'function' => $ callback [ 1 ] ) ; } } elseif ( class_exists ( $ callback , false ) ) { if ( is_subclass_of ( $ callback , 'Dwoo_Block_Plugin' ) ) { $ this -> plugins [ $ name ] = array ( 'type' => self :: BLOCK_PLUGIN | $ compilable , 'callback' => $ callback , 'class' => $ callback ) ; } else { $ this -> plugins [ $ name ] = array ( 'type' => self :: CLASS_PLUGIN | $ compilable , 'callback' => $ callback , 'class' => $ callback , 'function' => 'process' ) ; } } elseif ( function_exists ( $ callback ) ) { $ this -> plugins [ $ name ] = array ( 'type' => self :: FUNC_PLUGIN | $ compilable , 'callback' => $ callback ) ; } else { throw new Dwoo_Exception ( 'Callback could not be processed correctly, please check that the function/class you used exists' ) ; } }
adds a custom plugin that is not in one of the plugin directories
10,811
public function addFilter ( $ callback , $ autoload = false ) { if ( $ autoload ) { $ class = 'Dwoo_Filter_' . $ callback ; if ( ! class_exists ( $ class , false ) && ! function_exists ( $ class ) ) { try { $ this -> getLoader ( ) -> loadPlugin ( $ callback ) ; } catch ( Dwoo_Exception $ e ) { if ( strstr ( $ callback , 'Dwoo_Filter_' ) ) { throw new Dwoo_Exception ( 'Wrong filter name : ' . $ callback . ', the "Dwoo_Filter_" prefix should not be used, please only use "' . str_replace ( 'Dwoo_Filter_' , '' , $ callback ) . '"' ) ; } else { throw new Dwoo_Exception ( 'Wrong filter name : ' . $ callback . ', when using autoload the filter must be in one of your plugin dir as "name.php" containg a class or function named "Dwoo_Filter_name"' ) ; } } } if ( class_exists ( $ class , false ) ) { $ callback = array ( new $ class ( $ this ) , 'process' ) ; } elseif ( function_exists ( $ class ) ) { $ callback = $ class ; } else { throw new Dwoo_Exception ( 'Wrong filter name : ' . $ callback . ', when using autoload the filter must be in one of your plugin dir as "name.php" containg a class or function named "Dwoo_Filter_name"' ) ; } $ this -> filters [ ] = $ callback ; } else { $ this -> filters [ ] = $ callback ; } }
adds a filter to this Dwoo instance it will be used to filter the output of all the templates rendered by this instance
10,812
public function removeFilter ( $ callback ) { if ( ( $ index = array_search ( 'Dwoo_Filter_' . $ callback , $ this -> filters , true ) ) !== false ) { unset ( $ this -> filters [ $ index ] ) ; } elseif ( ( $ index = array_search ( $ callback , $ this -> filters , true ) ) !== false ) { unset ( $ this -> filters [ $ index ] ) ; } else { $ class = 'Dwoo_Filter_' . $ callback ; foreach ( $ this -> filters as $ index => $ filter ) { if ( is_array ( $ filter ) && $ filter [ 0 ] instanceof $ class ) { unset ( $ this -> filters [ $ index ] ) ; break ; } } } }
removes a filter
10,813
public function addResource ( $ name , $ class , $ compilerFactory = null ) { if ( strlen ( $ name ) < 2 ) { throw new Dwoo_Exception ( 'Resource names must be at least two-character long to avoid conflicts with Windows paths' ) ; } if ( ! class_exists ( $ class ) ) { throw new Dwoo_Exception ( 'Resource class does not exist' ) ; } $ interfaces = class_implements ( $ class ) ; if ( in_array ( 'Dwoo_ITemplate' , $ interfaces ) === false ) { throw new Dwoo_Exception ( 'Resource class must implement Dwoo_ITemplate' ) ; } $ this -> resources [ $ name ] = array ( 'class' => $ class , 'compiler' => $ compilerFactory ) ; }
adds a resource or overrides a default one
10,814
public function getLoader ( ) { if ( $ this -> loader === null ) { $ this -> loader = new Dwoo_Loader ( $ this -> getCompileDir ( ) ) ; } return $ this -> loader ; }
returns the current loader object or a default one if none is currently found
10,815
public function getCacheDir ( ) { if ( $ this -> cacheDir === null ) { $ this -> setCacheDir ( dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR ) ; } return $ this -> cacheDir ; }
returns the cache directory with a trailing DIRECTORY_SEPARATOR
10,816
public function setCacheDir ( $ dir ) { $ this -> cacheDir = rtrim ( $ dir , '/\\' ) . DIRECTORY_SEPARATOR ; if ( is_writable ( $ this -> cacheDir ) === false ) { throw new Dwoo_Exception ( 'The cache directory must be writable, chmod "' . $ this -> cacheDir . '" to make it writable' ) ; } }
sets the cache directory and automatically appends a DIRECTORY_SEPARATOR
10,817
public function getCompileDir ( ) { if ( $ this -> compileDir === null ) { $ this -> setCompileDir ( dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'compiled' . DIRECTORY_SEPARATOR ) ; } return $ this -> compileDir ; }
returns the compile directory with a trailing DIRECTORY_SEPARATOR
10,818
public function setCompileDir ( $ dir ) { $ this -> compileDir = rtrim ( $ dir , '/\\' ) . DIRECTORY_SEPARATOR ; if ( is_writable ( $ this -> compileDir ) === false ) { throw new Dwoo_Exception ( 'The compile directory must be writable, chmod "' . $ this -> compileDir . '" to make it writable' ) ; } }
sets the compile directory and automatically appends a DIRECTORY_SEPARATOR
10,819
private function getAllGenerators ( ) { $ allGenerators = array ( ) ; foreach ( fphp \ Generator \ Generator :: getGeneratorMap ( ) as $ key => $ klass ) $ allGenerators [ $ key ] = new $ klass ( $ this -> productLine -> getGeneratorSettings ( $ key ) ) ; return $ allGenerators ; }
Returns all generators . The generators are instantiated with their respective generator settings .
10,820
private function addArtifactToUsedGenerators ( $ allGenerators , $ feature , $ func ) { $ artifact = $ this -> productLine -> getArtifact ( $ feature ) ; foreach ( $ artifact -> getGenerators ( ) as $ key => $ cfg ) { if ( ! array_key_exists ( $ key , $ allGenerators ) ) throw new ProductException ( "\"$key\" is not a valid generator" ) ; call_user_func ( array ( $ allGenerators [ $ key ] , $ func ) , $ artifact ) ; } }
Adds a feature s artifact to all generators it specifies . This is done independently from whether the corresponding feature is selected or deselected to support generating code for both cases .
10,821
private function getGeneratorElements ( $ func ) { $ allGenerators = $ this -> getAllGenerators ( ) ; foreach ( $ this -> configuration -> getSelectedFeatures ( ) as $ feature ) $ this -> addArtifactToUsedGenerators ( $ allGenerators , $ feature , "addSelectedArtifact" ) ; foreach ( $ this -> configuration -> getDeselectedFeatures ( ) as $ feature ) $ this -> addArtifactToUsedGenerators ( $ allGenerators , $ feature , "addDeselectedArtifact" ) ; $ elements = array ( ) ; foreach ( $ allGenerators as $ generator ) if ( $ generator -> hasArtifacts ( ) ) $ elements = array_merge ( $ elements , call_user_func ( array ( $ generator , $ func ) ) ) ; return $ elements ; }
Returns elements generated for the product . To do this every artifact is registered with the generators it specifies . Then every generator generates some elements . Finally all the elements are merged .
10,822
public function generateFiles ( ) { $ files = $ this -> getGeneratorElements ( "generateFiles" ) ; $ files = fphp \ Helper \ _Array :: assertNoDuplicates ( $ files , "getTarget" ) ; $ files = fphp \ Helper \ _Array :: sortByKey ( $ files , "getTarget" ) ; return $ files ; }
Generates the product s files .
10,823
public function trace ( ) { $ tracingLinks = array_merge ( $ this -> getGeneratorElements ( "trace" ) , $ this -> getAllGenerators ( ) [ "runtime" ] -> traceRuntimeCalls ( $ this -> generateFiles ( ) , $ this -> productLine ) ) ; $ tracingLinks = fphp \ Helper \ _Array :: sortByKey ( $ tracingLinks , "getFeatureName" ) ; return $ tracingLinks ; }
Returns tracing links for the product .
10,824
public static function hasSessionMoved ( ) { if ( ! isset ( $ _SESSION [ 'dachi_agent' ] ) ) return true ; $ agents = $ _SESSION [ 'dachi_agent' ] ; $ agentc = $ _SERVER [ 'HTTP_USER_AGENT' ] ; if ( $ agents != $ agentc ) { if ( strpos ( $ agentc , "Trident" ) !== false && strpos ( $ agents , "Trident" ) !== false ) return false ; return true ; } return false ; }
Has this session moved
10,825
public static function isValid ( ) { if ( isset ( $ _SESSION [ 'dachi_closed' ] ) && ! isset ( $ _SESSION [ 'dachi_expires' ] ) ) return false ; if ( isset ( $ _SESSION [ 'dachi_expires' ] ) && $ _SESSION [ 'dachi_expires' ] < time ( ) ) return false ; return true ; }
Is this session still valid?
10,826
public static function regenerate ( ) { if ( isset ( $ _SESSION [ 'dachi_closed' ] ) && $ _SESSION [ 'dachi_closed' ] == true ) return false ; $ _SESSION [ 'dachi_closed' ] = true ; $ _SESSION [ 'dachi_expires' ] = time ( ) + 10 ; session_regenerate_id ( false ) ; $ new_session = session_id ( ) ; session_write_close ( ) ; session_id ( $ new_session ) ; session_start ( ) ; unset ( $ _SESSION [ 'dachi_closed' ] ) ; unset ( $ _SESSION [ 'dachi_expires' ] ) ; }
Regenerate the session for security
10,827
private function buildRadiusOptions ( ) { if ( ! $ this -> radius || ! isset ( $ GLOBALS [ 'TL_DCA' ] [ $ this -> strTable ] [ 'fields' ] [ $ this -> radius ] ) ) { return null ; } $ options = [ 'element' => 'ctrl_' . $ this -> radius , 'min' => 0 , 'max' => 0 , 'defaultValue' => 0 ] ; if ( isset ( $ GLOBALS [ 'TL_DCA' ] [ $ this -> strTable ] [ 'fields' ] [ $ this -> radius ] [ 'eval' ] ) ) { $ config = $ GLOBALS [ 'TL_DCA' ] [ $ this -> strTable ] [ 'fields' ] [ $ this -> radius ] [ 'eval' ] ; $ options [ 'min' ] = isset ( $ config [ 'minval' ] ) ? ( int ) $ config [ 'minval' ] : 0 ; $ options [ 'max' ] = isset ( $ config [ 'maxval' ] ) ? ( int ) $ config [ 'maxval' ] : 0 ; $ options [ 'defaultValue' ] = isset ( $ config [ 'default' ] ) ? ( int ) $ config [ 'default' ] : 0 ; $ options [ 'steps' ] = isset ( $ config [ 'steps' ] ) ? ( int ) $ config [ 'steps' ] : 0 ; } return $ options ; }
Build the radius options .
10,828
public static function createMany ( array $ datasets ) : array { $ models = [ ] ; foreach ( $ datasets as $ dataset ) { $ models [ ] = static :: create ( $ dataset ) ; } return $ models ; }
Creates many Models .
10,829
public function expires ( $ time ) { if ( ! empty ( $ time ) && is_string ( $ time ) && ! $ timestamp = strtotime ( $ time ) ) { throw new \ Ergo \ Routing \ Exception ( "Invalid expiry time: $timestamp" ) ; } else if ( is_numeric ( $ time ) ) { $ timestamp = $ time ; } else if ( $ time == false ) { return $ this ; } $ this -> addHeader ( 'Expires' , date ( 'r' , $ timestamp ) ) ; return $ this ; }
Sets the Expires header based on a Unix timestamp .
10,830
public function created ( $ location = null ) { $ this -> respondWith ( 201 ) ; if ( ! empty ( $ location ) ) { $ this -> setResponseHeader ( 'Location' , $ location ) ; } }
Response with created 201 code and optionally the created location
10,831
public function partialContent ( $ rangeFrom , $ rangeTo , $ totalSize ) { $ this -> respondWith ( 206 ) ; $ this -> setResponseHeader ( 'Content-Range' , "bytes {$rangeFrom}-{$rangeTo}/{$totalSize}" ) ; $ this -> setResponseHeader ( 'Content-Length' , $ rangeTo - $ rangeFrom ) ; }
Respond with a 206 Partial content with Content - Range header
10,832
public function redirect ( $ url , $ code = 303 ) { $ this -> respondWith ( $ code ) ; $ this -> setResponseHeader ( 'Location' , $ url ) ; $ urlHtml = htmlentities ( $ url ) ; $ this -> output ( 'You are being redirected to <a href="' . $ urlHtml . '">' . $ urlHtml . '</a>' , 'text/html' ) ; }
Redirect to url and output a short message with the link
10,833
protected function getContentType ( $ format ) { if ( \ Jasny \ str_contains ( $ format , '/' ) ) { return $ format ; } $ repository = new ApacheMimeTypes ( ) ; $ mime = $ repository -> findType ( $ format ) ; if ( ! isset ( $ mime ) ) { throw new \ UnexpectedValueException ( "Format '$format' doesn't correspond with a MIME type" ) ; } return $ mime ; }
Get MIME type for extension
10,834
protected function outputContentType ( $ format ) { if ( ! isset ( $ format ) ) { $ contentType = $ this -> getResponse ( ) -> getHeaderLine ( 'Content-Type' ) ; if ( empty ( $ contentType ) ) { $ format = $ this -> defaultFormat ? : 'text/html' ; } } if ( empty ( $ contentType ) ) { $ contentType = $ this -> getContentType ( $ format ) ; $ this -> setResponseHeader ( 'Content-Type' , $ contentType ) ; } return $ contentType ; }
Set the content type for the output
10,835
public function listFolder ( string $ path , bool $ recursive = false ) : array { $ path = $ this -> normalizePath ( $ path ) ; $ requestUrl = $ this -> siteUrl . '/sites/' . $ this -> siteName . '/_api/Web/GetFolderByServerRelativeUrl(\'' . $ this -> folderPath . $ path . '\')/Folders' ; $ options = [ 'headers' => $ this -> requestHeaders , ] ; $ response = $ this -> send ( 'GET' , $ requestUrl , $ options ) ; $ folders = json_decode ( $ response -> getBody ( ) ) -> d ?? [ 'results' => [ ] ] ; if ( ! is_array ( $ folders ) ) { $ folders = json_decode ( json_encode ( $ folders ) , true ) ; } return $ folders [ 'results' ] ; }
Returns the contents of a folder .
10,836
public function copy ( string $ fromPath , string $ toPath , array $ mimeType ) : bool { $ fromPath = $ this -> normalizePath ( $ fromPath ) ; $ toPath = $ this -> normalizePath ( $ toPath ) ; if ( substr ( $ mimeType [ 'mimetype' ] , 0 , 4 ) === 'text' ) { $ requestUrl = $ this -> siteUrl . '/sites/' . $ this -> siteName . '/_api/Web/GetFolderByServerRelativeUrl(\'' . $ this -> folderPath . $ fromPath . '\')/copyTo(strNewUrl=\'' . $ this -> folderPath . $ toPath . '\', bOverWrite=true)' ; } else { $ requestUrl = $ this -> siteUrl . '/sites/' . $ this -> siteName . '/_api/Web/GetFileByServerRelativeUrl(\'' . $ this -> folderPath . $ fromPath . '\')/copyTo(strNewUrl=\'' . $ this -> folderPath . $ toPath . '\', bOverWrite=true)' ; } $ options = [ 'headers' => $ this -> requestHeaders , ] ; $ response = $ this -> send ( 'POST' , $ requestUrl , $ options ) ; return $ response -> getStatusCode ( ) === 200 ? true : false ; }
Copy a file or folder to a different location .
10,837
public function images ( $ file , $ version = '' ) { if ( empty ( $ version ) ) { $ version = '?ver=' . Kecik :: $ version ; } return $ this -> BaseUrl . Config :: get ( 'path.assets' ) . '/images/' . $ file . $ version ; }
Create of images Url from Assets
10,838
public function url ( $ file = '' , $ version = '' ) { if ( empty ( $ version ) ) { $ version = '?ver=' . Kecik :: $ version ; } if ( ! empty ( $ file ) ) { return $ this -> BaseUrl . Config :: get ( 'path.assets' ) . '/' . $ file . $ version ; } else { return $ this -> BaseUrl . Config :: get ( 'path.assets' ) . '/' ; } }
Create url from assets
10,839
public function delete ( $ file ) { $ key = array_search ( $ file , $ this -> assets [ $ this -> type ] ) ; unset ( $ this -> assets [ $ this -> type ] [ $ key ] ) ; unset ( $ this -> attr [ $ this -> type ] [ $ key ] ) ; }
Delete Assets from register delete
10,840
protected function build_input ( $ data , array $ fields = [ ] ) { $ fields = implode ( ' ' , $ fields ) ; return sprintf ( '<input id="%1$s" name="%1$s" type="%2$s" %3$s value="%4$s" />' , $ this -> name , $ this -> type , $ fields , esc_attr ( $ data ) ) ; }
build input field
10,841
protected function constructDataModuleNamespace ( & $ data ) { if ( isset ( $ data -> module ) ) $ this -> SetModule ( $ data -> module ) ; if ( isset ( $ data -> namespace ) ) $ this -> SetNamespace ( $ data -> namespace ) ; }
If route is initialized by single array argument with all data initialize route application module name and optional target controllers namespace - used only if routed controller is not defined absolutely . Initialize both properties by setter methods .
10,842
public function transform ( $ route ) { $ route = $ this -> entityToArray ( Route :: class , $ route ) ; return [ 'id' => ( int ) $ route [ 'id' ] , 'createdAt' => $ route [ 'created_at' ] , 'updatedAt' => $ route [ 'updated_at' ] ] ; }
Transforms route entity
10,843
public function provide ( $ name , $ args ) { $ services = $ this -> getServices ( ) ; if ( isset ( $ services [ $ name ] ) ) { return ( new Service ( $ name , $ services [ $ name ] ) ) -> resolve ( $ args , $ this -> getDi ( ) ) ; } else { $ method = self :: METHOD_PREFIX . $ name ; if ( method_exists ( $ this , $ method ) ) { if ( empty ( $ args ) ) { return $ this -> $ method ( ) ; } else { return call_user_func_array ( [ $ this , $ method ] , $ args ) ; } } else { throw new Exception ( "Cannot load '{$name}' from " . get_class ( $ this ) ) ; } } }
Creates service instance
10,844
public function getNames ( ) { $ names = array_keys ( $ this -> getServices ( ) ) ; $ len = strlen ( self :: METHOD_PREFIX ) ; foreach ( get_class_methods ( $ this ) as $ method ) { if ( Text :: startsWith ( $ method , self :: METHOD_PREFIX ) ) { $ name = lcfirst ( substr ( $ method , $ len ) ) ; if ( $ name ) { $ names [ ] = $ name ; } } } return $ names ; }
Gets all service names
10,845
public function append ( ) { if ( ! $ this -> hasMultiHandle ( ) ) { $ this -> setMultiHandle ( curl_multi_init ( ) ) ; } $ this -> initOption ( ) -> buildBody ( ) ; $ curl = curl_init ( ) ; curl_setopt_array ( $ curl , $ this -> getOptions ( ) ) ; curl_multi_add_handle ( $ this -> getMultiHandle ( ) , $ curl ) ; $ this -> curls [ ] = $ curl ; }
add multi handle
10,846
public function validateModelId ( $ attribute , $ params ) { $ class = Model :: findIdentity ( $ this -> model_class ) ; if ( $ class === null ) { $ this -> addError ( $ attribute , \ Yii :: t ( 'net_frenzel_communication' , 'ERROR_MSG_INVALID_MODEL_ID' ) ) ; } else { $ model = $ class -> name ; if ( $ model :: find ( ) -> where ( [ 'id' => $ this -> entity_id ] ) === false ) { $ this -> addError ( $ attribute , \ Yii :: t ( 'net_frenzel_communication' , 'ERROR_MSG_INVALID_MODEL_ID' ) ) ; } } }
Model ID validation .
10,847
public static function getIPLocation ( ) { $ adapter = new GuzzleHttpAdapter ( ) ; $ geocoder = new \ Geocoder \ Provider \ FreeGeoIp ( $ adapter ) ; if ( ! isset ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) ) { $ client_ip = $ _SERVER [ 'REMOTE_ADDR' ] ; } else { $ client_ip = $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ; } return $ geocoder -> geocode ( $ client_ip ) ; }
find the use location based upon his current IP address
10,848
protected function handleInvalidMethod ( $ method ) { $ emptyResponse = new Response ( ) ; $ emptyResponse -> setHeader ( "HTTP/1.1 405 Method $method Not Allowed" , false ) ; $ emptyResponse -> setHeader ( "Allow" , implode ( ", " , $ this -> getSupportedHttpMethods ( ) ) ) ; throw new ForceResponseException ( $ emptyResponse ) ; }
Override to handle the case where an HTTP method is unsupported .
10,849
public function factory ( ) { $ redis = new \ Redis ( ) ; $ host = $ this -> getConfig ( ) -> getValue ( self :: CONFIG_HOST ) ; $ port = $ this -> getConfig ( ) -> getValue ( self :: CONFIG_PORT ) ; $ timeout = $ this -> getConfig ( ) -> getValue ( self :: CONFIG_TIMEOUT ) ; if ( $ this -> getConfig ( ) -> getValueFlag ( self :: CONFIG_PERSISTENT ) ) { $ redis -> pconnect ( $ host , $ port , $ timeout ) ; } else { $ redis -> connect ( $ host , $ port , $ timeout ) ; } if ( $ this -> getConfig ( ) -> hasValue ( self :: CONFIG_DATABASE ) ) { $ redis -> select ( $ this -> getConfig ( ) -> getValue ( self :: CONFIG_DATABASE ) ) ; } return $ redis ; }
Creates a configured \ Redis instance in the object context
10,850
public function setTemplateDir ( $ path = VIEW ) { $ old = $ this -> _sv_template_dir ; $ this -> _sv_template_dir = $ path ; return $ old ; }
changes the template directory
10,851
public function jsonDecode ( ) { $ json = json_decode ( $ this -> body , true ) ; if ( $ json === null ) { throw new JsonFormatException ( $ this -> body ) ; } return $ json ; }
Decode as JSON
10,852
protected function addFile ( Phar $ phar , SplFileInfo $ file , $ strip = true ) { $ path = strtr ( str_replace ( dirname ( dirname ( dirname ( __DIR__ ) ) ) . DIRECTORY_SEPARATOR , '' , $ file -> getRealPath ( ) ) , '\\' , '/' ) ; $ content = file_get_contents ( $ file ) ; if ( $ strip ) { $ content = $ this -> stripWhitespace ( $ content ) ; } elseif ( 'LICENSE' === basename ( $ file ) ) { $ content = "\n" . $ content . "\n" ; } if ( $ path === 'src/Composer/Composer.php' ) { $ content = str_replace ( '@package_version@' , $ this -> version , $ content ) ; $ content = str_replace ( '@release_date@' , $ this -> versionDate , $ content ) ; } $ phar -> addFromString ( $ path , $ content ) ; return $ this ; }
Add a file into the phar package
10,853
protected function addBin ( Phar $ phar ) { $ content = file_get_contents ( __DIR__ . '/../../../bin/visithor' ) ; $ content = preg_replace ( '{^#!/usr/bin/env php\s*}' , '' , $ content ) ; $ phar -> addFromString ( 'bin/visithor' , $ content ) ; return $ this ; }
Add bin into Phar
10,854
public function addCron ( CronInterface $ cron , $ alias , $ priority , $ arguments ) { if ( ! isset ( $ this -> crons [ $ priority ] ) ) { $ this -> crons [ $ priority ] = array ( ) ; } $ cron -> setAlias ( $ alias ) ; $ cron -> addArguments ( $ arguments ) ; $ cron -> addPriority ( $ priority ) ; $ this -> crons [ $ priority ] [ $ alias ] = $ cron ; }
Add cron to crons list
10,855
public function index ( $ request ) { $ application = $ request -> get ( 'application' ) ; $ path = $ request -> get ( 'path' ) ; if ( empty ( $ application ) || empty ( $ path ) ) { return new Response ( "Not a valid asset" , 404 ) ; } if ( strpos ( '..' , $ path ) === 0 ) { return new Response ( "Only assets will be served" , 404 ) ; } if ( $ application !== 'Towel' ) { $ asset_path = APP_ROOT_DIR . '/Application/' . $ application . '/Views/assets/' . $ path ; } else { $ asset_path = APP_FW_DIR . '/Views/assets/' . $ path ; } if ( ! file_exists ( $ asset_path ) ) { return new Response ( "Asset does not exists" , 404 ) ; } $ asset_type = mime_content_type ( $ asset_path ) ; $ asset_content = file_get_contents ( $ asset_path ) ; $ asset_info = pathinfo ( $ asset_path ) ; if ( ! empty ( $ asset_info [ 'extension' ] ) && in_array ( $ asset_info [ 'extension' ] , self :: $ validExtensions ) ) { $ response = new Response ( $ asset_content , 200 , [ 'Content-Type' => self :: $ extensionTypeMapping [ $ asset_info [ 'extension' ] ] ] ) ; $ maxAge = 0 ; if ( ! empty ( $ this -> appConfig [ 'assets' ] [ 'max-age' ] ) ) { $ maxAge = $ this -> appConfig [ 'assets' ] [ 'max-age' ] ; } $ response -> headers -> addCacheControlDirective ( 'max-age' , $ maxAge ) ; if ( ! empty ( $ this -> appConfig [ 'assets' ] [ 'public' ] ) && $ this -> appConfig [ 'assets' ] [ 'public' ] == true ) { $ response -> headers -> addCacheControlDirective ( 'public' , true ) ; } return $ response ; } return new Response ( "Not a valid extension" , 404 ) ; }
Serves assets from the Application directory .
10,856
public function createNewUser ( $ serviceName , AbstractUser $ response ) { $ data = $ this -> parseServiceResponse ( $ response ) ; $ existingUser = $ this -> userRepo -> getByEmail ( $ data [ 'email' ] ) ; if ( $ existingUser === null ) { $ data [ 'password' ] = str_random ( 40 ) ; $ user = $ this -> userRepo -> create ( $ data ) ; $ this -> addSocialRelation ( $ user , $ serviceName , $ response ) ; return $ user ; } else { session ( ) -> put ( 'url.intended' , route ( 'register' ) ) ; throw new SocialException ( trans ( 'gzero-social::common.email_already_in_use_message' , [ 'service_name' => title_case ( $ serviceName ) ] ) ) ; } }
Function creates new user based on social service response and create relation with social integration in database .
10,857
public function addUserSocialAccount ( User $ user , $ serviceName , AbstractUser $ response ) { $ user -> has_social_integrations = true ; $ user -> save ( ) ; $ this -> addSocialRelation ( $ user , $ serviceName , $ response ) ; return $ user ; }
Function adds new social account for existing user .
10,858
public function addSocialRelation ( User $ user , $ serviceName , AbstractUser $ response ) { return $ this -> newQB ( ) -> insert ( [ 'user_id' => $ user -> id , 'social_id' => $ serviceName . '_' . $ response -> id , 'created_at' => \ DB :: raw ( 'NOW()' ) ] ) ; }
Function creates relation for given user and social integration .
10,859
private function parseServiceResponse ( AbstractUser $ response ) { $ userData = [ 'has_social_integrations' => true , 'nick' => $ response -> getNickname ( ) ] ; if ( $ response -> getEmail ( ) ) { $ userData [ 'email' ] = $ response -> getEmail ( ) ; } else { $ userData [ 'email' ] = uniqid ( 'social_' , true ) ; } $ name = explode ( " " , $ response -> getName ( ) ) ; if ( count ( $ name ) >= 2 ) { $ userData [ 'first_name' ] = $ name [ 0 ] ; $ userData [ 'last_name' ] = $ name [ 1 ] ; } return $ userData ; }
Function parses social service response and prepares user data to insert to database .
10,860
public function executeQueryCopy ( Transformation $ transformation ) { $ path = $ transformation -> getSourceAsPath ( ) ; if ( ! is_readable ( $ path ) ) { throw new Exception ( 'Unable to read the source file: ' . $ path ) ; } if ( ! is_writable ( $ transformation -> getTransformer ( ) -> getTarget ( ) ) ) { throw new Exception ( 'Unable to write to: ' . dirname ( $ transformation -> getArtifact ( ) ) ) ; } $ filesystem = new Filesystem ( ) ; if ( is_file ( $ path ) ) { $ filesystem -> copy ( $ path , $ transformation -> getArtifact ( ) , true ) ; } else { $ filesystem -> mirror ( $ path , $ transformation -> getArtifact ( ) , null , array ( 'override' => true ) ) ; } }
Copies files or folders to the Artifact location .
10,861
public function loadConfiguration ( ) { $ builder = $ this -> getContainerBuilder ( ) ; $ config = $ this -> getConfig ( $ this -> defaults ) ; $ menuFactory = $ builder -> addDefinition ( $ this -> prefix ( 'extension' ) ) -> setClass ( 'Smf\Menu\MenuExtension' ) ; $ menuFactory = $ builder -> addDefinition ( $ this -> prefix ( 'factory' ) ) -> addSetup ( 'addExtension' , array ( $ this -> prefix ( '@extension' ) ) ) -> setClass ( 'Knp\Menu\MenuFactory' ) ; $ rendererManager = $ builder -> addDefinition ( $ this -> prefix ( 'rendererManager' ) ) -> setClass ( 'Smf\Menu\Renderer\Manager' ) -> addSetup ( get_called_class ( ) . '::setupRenderers' , array ( '@self' , '@container' ) ) -> addSetup ( 'setDefaultRenderer' , array ( $ config [ 'defaultRenderer' ] ) ) ; ; $ builder -> addDefinition ( $ this -> prefix ( 'controlFactory' ) ) -> setClass ( 'Smf\Menu\Control\Factory' , array ( $ menuFactory , $ rendererManager ) ) ; $ matcher = $ builder -> addDefinition ( $ this -> prefix ( 'matcher' ) ) -> addSetup ( get_called_class ( ) . '::setupVoters' , array ( '@self' , '@container' ) ) -> setClass ( 'Smf\Menu\Matcher\Matcher' ) ; $ renderers = array ( 'Smf\Menu\Renderer\ListRenderer' , 'Smf\Menu\Renderer\BootstrapNavRenderer' , ) ; foreach ( $ renderers as $ renderer ) { $ name = explode ( '\\' , $ renderer ) ; $ name = lcfirst ( preg_replace ( '#Renderer$#' , '' , end ( $ name ) ) ) ; $ builder -> addDefinition ( $ this -> prefix ( 'renderer_' . $ name ) ) -> setClass ( $ renderer , array ( $ matcher ) ) -> addTag ( self :: RENDERER_TAG_NAME , $ name ) ; } $ builder -> addDefinition ( $ this -> prefix ( 'presenterVoter' ) ) -> setClass ( 'Smf\Menu\Matcher\Voter\PresenterVoter' ) -> addTag ( self :: VOTER_TAG_NAME ) ; }
Configuration - container building
10,862
public static function register ( Nette \ Configurator $ configurator , $ name = self :: DEFAULT_EXTENSION_NAME ) { $ class = get_called_class ( ) ; $ configurator -> onCompile [ ] = function ( Nette \ Configurator $ configurator , Nette \ DI \ Compiler $ compiler ) use ( $ class , $ name ) { $ compiler -> addExtension ( $ name , new $ class ) ; } ; }
Register extension to compiler .
10,863
public function hasEnabledInvitationRegistration ( ) { if ( $ this -> invitationRegistrationClass === false || ! is_string ( $ this -> invitationRegistrationClass ) || ! class_exists ( $ this -> invitationRegistrationClass ) ) { return false ; } return true ; }
Check whether this user enables the invitation from registration feature or not .
10,864
public function setColumn ( $ name , $ value ) { foreach ( $ this -> entities as $ entity ) { $ entity -> set ( $ name , $ value ) ; } return $ this ; }
Set the value of a column for all entities in this collection . Setter methods will be called .
10,865
public function setColumnRaw ( $ name , $ value ) { foreach ( $ this -> entities as $ entity ) { $ entity -> setRaw ( $ name , $ value ) ; } return $ this ; }
Set the value of a column for all entities in this collection . Setter methods will not be called .
10,866
public function getColumn ( $ name ) { $ results = [ ] ; foreach ( $ this -> entities as $ entity ) { $ results [ ] = $ entity -> get ( $ name ) ; } return $ results ; }
Get the values of a single column from all entities in this collection . Getter methods will be called .
10,867
public function getColumnRaw ( $ name ) { $ results = [ ] ; foreach ( $ this -> entities as $ entity ) { $ results [ ] = $ entity -> getRaw ( $ name ) ; } return $ results ; }
Get the values of a single column from all entities in this collection . Getter methods will not be called .
10,868
public function getOne ( $ column , $ value , $ strict = true ) { if ( $ strict ) { foreach ( $ this -> entities as $ entity ) { if ( $ entity -> get ( $ column ) === $ value ) { return $ entity ; } } } else { foreach ( $ this -> entities as $ entity ) { if ( $ entity -> get ( $ column ) == $ value ) { return $ entity ; } } } return ; }
Get a single Entity from this collection where column = value . If more than one Entity is matched the first will be returned . If no Entity is matched null will be returned .
10,869
public function getRandom ( ) { return empty ( $ this -> entities ) ? null : $ this -> entities [ array_rand ( $ this -> entities ) ] ; }
Get a random Entity from this collection or null if the collection is empty .
10,870
public function remove ( $ column , $ value ) { foreach ( $ this -> entities as $ index => $ entity ) { if ( $ entity -> get ( $ column ) === $ value ) { unset ( $ this -> entities [ $ index ] ) ; $ this -> entities = array_values ( $ this -> entities ) ; return $ entity ; } } return ; }
Remove a single Entity from this collection where column = value . If more than one Entity is matched the first will be removed and returned . If no Entity is matched null will be returned .
10,871
public function removeRandom ( ) { $ index = array_rand ( $ this -> entities ) ; $ entity = $ this -> entities [ $ index ] ; unset ( $ this -> entities [ $ index ] ) ; return $ entity ; }
Remove a random Entity from this collection or null if the collection is empty .
10,872
public static function term ( $ pid , $ lagger_timeout = 0 , $ signal = SIGTERM ) { $ kill_time = time ( ) + $ lagger_timeout ; $ term = self :: signal ( $ pid , $ signal ) ; while ( time ( ) < $ kill_time ) { if ( ! self :: isRunning ( $ pid ) ) return $ term ; usleep ( 20000 ) ; } return self :: kill ( $ pid ) ; }
Terminate a process asking PID to terminate or killing it directly .
10,873
public static function setNiceness ( $ niceness , $ pid = null ) { return is_null ( $ pid ) ? @ proc_nice ( $ niceness ) : @ pcntl_setpriority ( $ pid , $ niceness ) ; }
Set niceness of a running process
10,874
public static function calc_base_directory_for_object ( DataObject $ do ) { $ str = 'dataobjects' ; $ ancestry = $ do -> getClassAncestry ( ) ; foreach ( $ ancestry as $ c ) { if ( $ c == 'SiteTree' ) { $ str = 'pages' ; } } switch ( $ do -> ClassName ) { case 'SiteConfig' : $ str = 'site' ; break ; default : } return $ str ; }
Base rules .
10,875
public function delete_index ( string $ table , string $ key ) : bool { if ( ( $ table = $ this -> table_full_name ( $ table , 1 ) ) && bbn \ str :: check_name ( $ key ) ) { return ( bool ) $ this -> db -> query ( "ALTER TABLE $table DROP INDEX `$key`" ) ; } return false ; }
Deletes an index
10,876
public function addRoute ( Route $ route ) { foreach ( $ route -> getMethods ( ) as $ method ) { $ this -> routes [ $ method ] [ ] = $ route ; } $ this -> allRoutes [ ] = $ route ; return $ this ; }
Add a Route instans to application routes .
10,877
protected function rglob ( $ pattern , $ excludes = array ( ) ) { $ files = array ( ) ; foreach ( glob ( $ pattern , 0 ) as $ item ) { if ( ! empty ( $ excludes ) && in_array ( ltrim ( $ item , '\.\/' ) , $ excludes ) ) { $ this -> trace ( "Skipping excluded item ./%s" , ltrim ( $ item , '\.\/' ) ) ; continue ; } if ( is_dir ( $ item ) ) { $ this -> debug ( "Globbing files in directory %s" , $ item ) ; $ files = array_merge ( $ files , $ this -> rglob ( $ item . '/*' , $ excludes ) ) ; } else { array_push ( $ files , ltrim ( $ item , '\.\/' ) ) ; } } return $ files ; }
Recursively globs all the files and directories using the given pattern . If any file or directory exists in the list of excluded items it is skipped
10,878
private function amendDynamicAttributesToJson ( array & $ json ) { if ( ! is_null ( $ this -> package_version ) ) { $ json [ 'version' ] = array ( ) ; $ json [ 'version' ] [ 'release' ] = $ this -> package_version ; } if ( ! is_null ( $ this -> package_name ) ) { $ json [ 'name' ] = $ this -> package_name ; } }
Adds attributes given from command line to the json
10,879
public function getValue ( $ feature ) { $ defaultValue = $ feature -> getDefaultValue ( ) ; $ values = $ this -> xmlConfiguration -> getValues ( ) ; if ( array_key_exists ( $ feature -> getName ( ) , $ values ) ) return $ values [ $ feature -> getName ( ) ] ; else return $ defaultValue ; }
Returns the configuration s value for a value feature .
10,880
public function renderAnalysis ( $ productLine = null , $ textOnly = false ) { return ( new ConfigurationRenderer ( $ this , $ productLine ) ) -> render ( $ textOnly ) ; }
Analyzes the model and configuration by returning a web page .
10,881
protected function get_field ( \ WP_Post $ post ) { $ field = parent :: get_field ( $ post ) ; if ( $ this -> prefix ) { $ field = $ this -> prefix . ' ' . $ field ; } if ( $ this -> suffix ) { $ field .= $ this -> suffix ; } return $ field ; }
Add suffix or prefix to field
10,882
public function getSortedModuleList ( ) : array { $ moduleList = $ this -> modules ; foreach ( $ moduleList as $ moduleSpec ) { $ moduleClass = $ moduleSpec [ 'class' ] ; $ module = $ moduleSpec [ 'object' ] ; if ( $ module instanceof OrderAwareModule ) { foreach ( $ module -> getModulesAfter ( ) as $ afterModuleClass ) { if ( \ array_key_exists ( $ afterModuleClass , $ moduleList ) ) { $ moduleList [ $ moduleClass ] [ 'after' ] [ ] = $ afterModuleClass ; $ moduleList [ $ afterModuleClass ] [ 'before' ] [ ] = $ moduleClass ; } } foreach ( $ module -> getModulesBefore ( ) as $ afterModuleClass ) { if ( \ array_key_exists ( $ afterModuleClass , $ moduleList ) ) { $ moduleList [ $ moduleClass ] [ 'before' ] [ ] = $ afterModuleClass ; $ moduleList [ $ afterModuleClass ] [ 'after' ] [ ] = $ moduleClass ; } } } } $ sortedList = [ ] ; $ noIncomingNodes = [ ] ; foreach ( $ moduleList as $ moduleSpec ) { $ moduleSpec [ 'after' ] = \ array_unique ( $ moduleSpec [ 'after' ] ) ; $ moduleSpec [ 'before' ] = \ array_unique ( $ moduleSpec [ 'before' ] ) ; if ( empty ( $ moduleSpec [ 'before' ] ) ) { $ noIncomingNodes [ $ moduleSpec [ 'class' ] ] = $ moduleSpec ; } } while ( ! empty ( $ noIncomingNodes ) ) { $ moduleSpec = array_shift ( $ noIncomingNodes ) ; \ array_push ( $ sortedList , $ moduleSpec ) ; unset ( $ moduleList [ $ moduleSpec [ 'class' ] ] ) ; foreach ( $ moduleSpec [ 'after' ] as $ nextModuleKey => $ nextModuleClass ) { unset ( $ moduleList [ $ nextModuleClass ] [ 'before' ] [ \ array_search ( $ moduleSpec [ 'class' ] , $ moduleList [ $ nextModuleClass ] [ 'before' ] ) ] ) ; if ( empty ( $ moduleList [ $ nextModuleClass ] [ 'before' ] ) ) { $ noIncomingNodes [ ] = $ moduleList [ $ nextModuleClass ] ; } unset ( $ moduleSpec [ 'after' ] [ $ nextModuleKey ] ) ; } } foreach ( $ moduleList as $ key => $ remainingModuleSpec ) { if ( empty ( $ remainingModuleSpec [ 'before' ] ) ) { $ sortedList [ ] = $ moduleList [ $ remainingModuleSpec [ 'class' ] ] ; unset ( $ moduleList [ $ key ] ) ; } } if ( ! empty ( $ moduleList ) ) { throw new CircularModuleLoadOrderDetectedException ( $ this -> getDotGraph ( ) ) ; } else { $ result = [ ] ; foreach ( $ sortedList as $ moduleSpec ) { $ result [ ] = $ moduleSpec [ 'object' ] ; } return $ result ; } }
Returns a list of modules sorted by dependencies .
10,883
public function afterAddingComment ( $ comment , $ notification ) { $ contentID = $ comment -> attribute ( 'contentobject_id' ) ; $ languageID = $ comment -> attribute ( 'language_id' ) ; $ subscriptionType = 'ezcomcomment' ; $ subscription = ezcomSubscriptionManager :: instance ( ) ; $ user = eZUser :: instance ( ) ; if ( $ notification === true ) { $ subscription -> addSubscription ( $ comment -> attribute ( 'email' ) , $ user , $ contentID , $ languageID , $ subscriptionType , $ comment -> attribute ( 'created' ) ) ; } if ( ezcomSubscription :: exists ( $ contentID , $ languageID , $ subscriptionType , null , 1 ) ) { $ notification = ezcomNotification :: create ( ) ; $ notification -> setAttribute ( 'contentobject_id' , $ comment -> attribute ( 'contentobject_id' ) ) ; $ notification -> setAttribute ( 'language_id' , $ comment -> attribute ( 'language_id' ) ) ; $ notification -> setAttribute ( 'comment_id' , $ comment -> attribute ( 'id' ) ) ; $ notification -> store ( ) ; eZDebugSetting :: writeNotice ( 'extension-ezcomments' , 'Notification added to queue' , __METHOD__ ) ; } }
add subscription after adding comment 1 ) If notification is true add the user as a subscriber if subscriber with same email doesn t exist otherwise get the subscriber 2 ) If notification is true if the subscription with user s email and contentid doesn t exist add a new subscription 3 ) If there is subscription add the comment into notifiction queue
10,884
public function afterUpdatingComment ( $ comment , $ notified , $ time ) { $ user = eZUser :: fetch ( $ comment -> attribute ( 'user_id' ) ) ; $ contentID = $ comment -> attribute ( 'contentobject_id' ) ; $ languageID = $ comment -> attribute ( 'language_id' ) ; $ subscriptionType = 'ezcomcomment' ; if ( ! is_null ( $ notified ) ) { $ subscriptionManager = ezcomSubscriptionManager :: instance ( ) ; if ( $ notified === true ) { try { $ subscriptionManager -> addSubscription ( $ comment -> attribute ( 'email' ) , $ user , $ contentID , $ languageID , $ subscriptionType , $ time , false ) ; } catch ( Exception $ e ) { eZDebug :: writeError ( $ e -> getMessage ( ) , __METHOD__ ) ; switch ( $ e -> getCode ( ) ) { case ezcomSubscriptionManager :: ERROR_SUBSCRIBER_DISABLED : return 'The subscriber is disabled.' ; default : return false ; } } } else { $ subscriptionManager -> deleteSubscription ( $ comment -> attribute ( 'email' ) , $ comment -> attribute ( 'contentobject_id' ) , $ comment -> attribute ( 'language_id' ) ) ; } } if ( ezcomSubscription :: exists ( $ contentID , $ languageID , $ subscriptionType ) ) { $ notification = ezcomNotification :: create ( ) ; $ notification -> setAttribute ( 'contentobject_id' , $ comment -> attribute ( 'contentobject_id' ) ) ; $ notification -> setAttribute ( 'language_id' , $ comment -> attribute ( 'language_id' ) ) ; $ notification -> setAttribute ( 'comment_id' , $ comment -> attribute ( 'id' ) ) ; $ notification -> store ( ) ; eZDebugSetting :: writeNotice ( 'extension-ezcomments' , 'There are subscriptions, added an update notification to the queue.' , __METHOD__ ) ; } else { } return true ; }
clean up subscription after updating comment
10,885
public function authenticate ( ) { $ request = new Request ( $ this -> handler ) ; $ this -> token = $ request -> execute ( RequestMethods :: HTTP_POST , $ this -> makeUrl ( RequestMethods :: DOMUSERP_API_PEDIDOVENDA . '/auth' ) , [ 'json' => [ 'login' => $ this -> username , 'password' => $ this -> password ] ] ) -> token ; return $ this ; }
Request an access token and sets it to the client .
10,886
private function plugins_loaded ( ) { if ( $ this -> _plugins_loaded ) { return ; } $ this -> _plugins_loaded = true ; spl_autoload_register ( function ( $ class ) { return $ this -> get_main ( ) -> load_class ( $ class ) ; } ) ; $ this -> load_functions ( ) ; }
load basic files
10,887
private function load_functions ( ) { if ( $ this -> is_theme ) { return ; } $ functions = $ this -> define -> plugin_dir . DS . 'functions.php' ; if ( is_readable ( $ functions ) ) { require_once $ functions ; } }
load functions file
10,888
private function resolveQsen ( $ link ) { if ( ! $ this -> isFqsen ( $ link ) ) { $ typeCollection = new TypeCollection ( array ( $ link ) , $ this -> createDocBlockContext ( ) ) ; $ link = $ typeCollection [ 0 ] ; } return $ link ; }
Resolves a QSEN to a FQSEN .
10,889
private function findElement ( $ fqsen ) { return isset ( $ this -> elementCollection [ $ fqsen ] ) ? $ this -> elementCollection [ $ fqsen ] : null ; }
Tries to find an element with the given FQSEN in the elements listing for this project .
10,890
public function getMenu ( $ level = 1 ) { if ( class_exists ( ContentController :: class ) ) { $ controller = Injector :: inst ( ) -> get ( ContentController :: class ) ; return $ controller -> getMenu ( $ level ) ; } }
If content controller exists return it s menu function
10,891
public function index ( SS_HTTPRequest $ request ) { $ this -> customise ( array ( 'Title' => _t ( 'Users.Register' , 'Register' ) , 'MetaTitle' => _t ( 'Users.Register' , 'Register' ) , 'Form' => $ this -> RegisterForm ( ) , ) ) ; $ this -> extend ( "updateIndexAction" ) ; return $ this -> renderWith ( array ( "Users_Register" , "Users" , "Page" ) ) ; }
Default action this controller will deal with
10,892
public function check ( $ file , $ verify = null ) { if ( is_string ( $ verify ) ) { $ verify = "lead" . strtoupper ( $ verify ) ; } $ detectives = [ ] ; foreach ( $ this -> detectives as $ detectiveClass ) { if ( $ detectiveClass :: on ( ) ) { $ detectives [ ] = $ detectiveClass ; } } $ case = null ; foreach ( $ detectives as $ detectiveClass ) { $ detective = new $ detectiveClass ( ) ; $ case = $ detective -> check ( $ file , $ verify ) ; if ( $ case ) { return $ detective ; } } return false ; }
Runs the file against all dectives .
10,893
public function setDataDirectory ( string $ directory ) { if ( ! is_dir ( $ directory ) ) { $ exception = new StorageException ( sprintf ( StorageException :: DIRECTORY_NOT_FOUND , $ directory ) ) ; $ exception -> setDirectory ( $ exception ) ; $ exception -> setProvider ( static :: class ) ; throw $ exception ; } $ this -> dataDirectory = $ directory ; }
Set data directory
10,894
public function active ( ) { if ( ! \ Yii :: $ app -> user -> isGuest && ! \ Yii :: $ app -> user -> identity -> isAdmin ) { $ this -> andWhere ( [ 'deleted_at' => NULL ] ) ; } return $ this ; }
only none delted records should be returned deleted would mean they are not null anymore within field value
10,895
public function related ( $ entity = NULL , $ enity = NULL ) { $ this -> andWhere ( [ 'entity' => $ entity , 'entity_id' => $ this -> entity_id ] ) ; return $ this ; }
find all records which are related to the same entity
10,896
public function processClass ( ProjectDescriptor $ project , Transformation $ transformation ) { try { $ this -> checkIfGraphVizIsInstalled ( ) ; } catch ( \ Exception $ e ) { echo $ e -> getMessage ( ) ; return ; } if ( $ transformation -> getParameter ( 'font' ) !== null && $ transformation -> getParameter ( 'font' ) -> getValue ( ) ) { $ this -> nodeFont = $ transformation -> getParameter ( 'font' ) -> getValue ( ) ; } else { $ this -> nodeFont = 'Courier' ; } $ filename = $ this -> getDestinationPath ( $ transformation ) ; $ graph = GraphVizGraph :: create ( ) -> setRankSep ( '1.0' ) -> setCenter ( 'true' ) -> setRank ( 'source' ) -> setRankDir ( 'RL' ) -> setSplines ( 'true' ) -> setConcentrate ( 'true' ) ; $ this -> buildNamespaceTree ( $ graph , $ project -> getNamespace ( ) ) ; $ classes = $ project -> getIndexes ( ) -> get ( 'classes' , new Collection ( ) ) -> getAll ( ) ; $ interfaces = $ project -> getIndexes ( ) -> get ( 'interfaces' , new Collection ( ) ) -> getAll ( ) ; $ traits = $ project -> getIndexes ( ) -> get ( 'traits' , new Collection ( ) ) -> getAll ( ) ; $ containers = array_merge ( $ classes , $ interfaces , $ traits ) ; foreach ( $ containers as $ container ) { $ from_name = $ container -> getFullyQualifiedStructuralElementName ( ) ; $ parents = array ( ) ; $ implemented = array ( ) ; if ( $ container instanceof ClassDescriptor ) { if ( $ container -> getParent ( ) ) { $ parents [ ] = $ container -> getParent ( ) ; } $ implemented = $ container -> getInterfaces ( ) -> getAll ( ) ; } if ( $ container instanceof InterfaceDescriptor ) { $ parents = $ container -> getParent ( ) -> getAll ( ) ; } foreach ( $ parents as $ parent ) { $ edge = $ this -> createEdge ( $ graph , $ from_name , $ parent ) ; $ edge -> setArrowHead ( 'empty' ) ; $ graph -> link ( $ edge ) ; } foreach ( $ implemented as $ parent ) { $ edge = $ this -> createEdge ( $ graph , $ from_name , $ parent ) ; $ edge -> setStyle ( 'dotted' ) ; $ edge -> setArrowHead ( 'empty' ) ; $ graph -> link ( $ edge ) ; } } $ graph -> export ( 'svg' , $ filename ) ; }
Creates a class inheritance diagram .
10,897
public function add ( $ alias , $ source = null , $ dependencies = [ ] , $ options = [ ] ) { if ( $ source !== null ) { $ asset = $ this -> _factory -> create ( $ alias , $ source , $ dependencies , $ options ) ; $ this -> _collection -> add ( $ asset ) ; } $ this -> _queued [ $ alias ] = true ; return $ this ; }
Adds a registered asset or a new asset to the queue .
10,898
public function register ( $ alias , $ source = null , $ dependencies = [ ] , $ options = [ ] ) { $ asset = $ this -> _factory -> create ( $ alias , $ source , $ dependencies , $ options ) ; $ this -> _collection -> add ( $ asset ) ; return $ this ; }
Registers an asset .
10,899
public function unregister ( $ alias ) { $ this -> _collection -> remove ( $ alias ) ; $ this -> remove ( $ alias ) ; return $ this ; }
Unregisters an asset from collection .