idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
235,600
public function destruct ( ) { $ this -> _id = [ ] ; $ this -> _source_db = null ; $ this -> _record = [ ] ; $ this -> _changed = [ ] ; return $ this ; }
Remove the data from this object after removal
235,601
public function getField ( string $ field ) { if ( isset ( $ this -> _record [ $ field ] ) ) return $ this -> _record [ $ field ] ; return null ; }
Get the value for a field of this record .
235,602
public function setField ( string $ field , $ value ) { if ( isset ( $ this -> _record [ $ field ] ) && $ this -> _record [ $ field ] === $ value ) return ; $ db = $ this -> getDB ( ) ; $ dao = $ db -> getDAO ( static :: class ) ; $ columns = $ dao -> getColumns ( ) ; if ( ! isset ( $ columns [ $ field ] ) ) throw new ...
Set a field to a new value . The value will be validated first by calling validate .
235,603
public static function validate ( Column $ coldef , $ value ) { $ field = $ coldef -> getName ( ) ; try { $ valid = $ coldef -> validate ( $ value ) ; } catch ( InvalidValueException $ e ) { $ rep = WF :: str ( $ value ) ; throw new InvalidValueException ( "Field $field cannot be set to $rep: {$e->getMessage()}" ) ; } ...
Validate a value for the field before setting it . This method is called from the setField method before updating the value . You can override this to add validators . Be sure to call the super validator to validate the base field to match the column definition .
235,604
protected function storageFormat ( $ key , $ data , $ ttl ) { $ start = time ( ) ; $ expire = $ start + $ ttl ; return array ( 'key' => $ key , 'value' => $ data , 'duration' => $ ttl , 'created' => $ start , 'expires' => $ expire ) ; }
Defines the array that will be used to store data . Changing this will require updating all functions that also fetch data .
235,605
public function detailsAction ( Request $ request , $ module , $ template , $ skins ) { $ fullModule = null ; try { $ moduleManager = $ this -> get ( 'terrific.composer.module.manager' ) ; $ fullModule = $ moduleManager -> getModuleByName ( $ module ) ; $ template = $ fullModule -> getTemplateByName ( $ template ) -> g...
Display the details of a terrific module .
235,606
public function createAction ( Request $ request ) { if ( $ this -> get ( 'session' ) -> has ( 'module' ) ) { $ tmpModule = $ this -> get ( 'session' ) -> get ( 'module' ) ; $ module = new Module ( ) ; $ module -> setStyle ( $ tmpModule -> getStyle ( ) ) ; } else { $ module = new Module ( ) ; $ module -> setStyle ( 'le...
Creates a terrific module .
235,607
public function addskinAction ( Request $ request ) { $ skin = new Skin ( ) ; $ module = new Module ( ) ; if ( $ this -> get ( 'session' ) -> has ( 'module' ) ) { $ tmpModule = $ this -> get ( 'session' ) -> get ( 'module' ) ; $ skin -> setModule ( $ tmpModule -> getName ( ) ) ; $ skin -> setStyle ( $ tmpModule -> getS...
Adds a skin to the module .
235,608
private function runRouteBinding ( ) : void { $ pathway = $ this -> getPathInfo ( ) ; $ routing = App :: $ Properties -> getAll ( 'Routing' ) ; if ( Any :: isArray ( $ routing ) && isset ( $ routing [ 'Alias' ] , $ routing [ 'Alias' ] [ env_name ] ) ) { $ pathway = $ this -> findStaticAliases ( $ routing [ 'Alias' ] [ ...
Build static and dynamic path aliases for working set
235,609
private function findStaticAliases ( ? array $ map = null , ? string $ pathway = null ) : ? string { if ( ! $ map ) { return $ pathway ; } if ( Arr :: in ( $ pathway , $ map ) ) { $ binding = array_search ( $ pathway , $ map , true ) ; $ url = $ this -> getSchemeAndHttpHost ( ) . $ this -> getBasePath ( ) . '/' ; if ( ...
Prepare static pathway aliasing for routing
235,610
private function findDynamicCallbacks ( array $ map = null , ? string $ controller = null ) : void { if ( ! $ map ) { return ; } if ( array_key_exists ( $ controller , $ map ) ) { $ class = ( string ) $ map [ $ controller ] ; if ( ! Str :: likeEmpty ( $ class ) ) { $ this -> callbackClass = $ class ; } } }
Prepare dynamic callback data for routing
235,611
public function serialize ( SearchCondition $ searchCondition ) : array { $ setName = $ searchCondition -> getFieldSet ( ) -> getSetName ( ) ; return [ $ setName , serialize ( $ searchCondition -> getValuesGroup ( ) ) ] ; }
Serialize a SearchCondition .
235,612
public function unserialize ( array $ searchCondition ) : SearchCondition { if ( 2 !== \ count ( $ searchCondition ) || ! isset ( $ searchCondition [ 0 ] , $ searchCondition [ 1 ] ) ) { throw new InvalidArgumentException ( 'Serialized search condition must be exactly two values [FieldSet-name, serialized ValuesGroup].'...
Unserialize a serialized SearchCondition .
235,613
public static function getCurrentFullHostString ( ) { $ hostString = $ _SERVER [ "HTTPS" ] ? "https" : "http" ; $ hostString .= "://" ; $ hostString .= $ _SERVER [ "HTTP_HOST" ] ; $ hostString .= $ _SERVER [ "SERVER_PORT" ] != 80 ? ":" . $ _SERVER [ "SERVER_PORT" ] : "" ; return $ hostString ; }
Return the current full host string for the current request including protocol and ports etc .
235,614
public function getPartialURLFromSegment ( $ segmentIdx ) { $ partialURL = "" ; for ( $ i = $ segmentIdx ; $ i < sizeof ( $ this -> segments ) ; $ i ++ ) { $ partialURL .= ( ( $ i > $ segmentIdx ) ? "/" : "" ) . $ this -> segments [ $ i ] ; } return $ partialURL ; }
Get a partial string version of this url object starting from a particular segment
235,615
public function getQueryParametersArray ( ) { $ queryString = $ this -> getQueryString ( ) ; if ( strlen ( $ queryString ) == 0 ) return array ( ) ; $ splitQuery = explode ( "&" , substr ( $ queryString , 1 ) ) ; $ returnedParams = array ( ) ; foreach ( $ splitQuery as $ param ) { $ splitParam = explode ( "=" , $ param...
Get all query parameters contained within this URL as an associative array .
235,616
private function processURL ( $ url ) { $ url = str_replace ( "%20" , " " , $ url ) ; $ this -> url = URLHelper :: $ testURL == null ? $ url : URLHelper :: $ testURL ; if ( substr ( $ url , 0 , 4 ) == "http" ) { $ splitProtocol = explode ( "://" , $ url ) ; $ requestSection = sizeof ( $ splitProtocol ) > 1 ? $ splitPro...
off query parameters too .
235,617
private function addInheritedAttributes ( ClassMetadata $ subClass , ClassMetadata $ parentClass ) { $ propertyFactory = new PropertyMetadataFactory ( $ subClass ) ; foreach ( $ parentClass -> propertyMetadata as $ attributeName => $ parentMapping ) { if ( $ subClass -> isEmbeddedDocument && $ parentMapping -> strategy...
Adds inherited attributes to the subclass mapping .
235,618
public function renderAncestorsAndSelf ( $ items , $ glue = '/' , $ keys = [ 'name' ] ) { $ items = $ items -> map ( function ( $ item , $ key ) use ( $ keys , $ glue ) { $ ancSelf = $ item -> ancestorsAndSelf ( ) -> get ( ) ; $ result = [ 'id' => $ item -> id ] ; foreach ( $ keys as $ k ) { $ plucks = $ ancSelf -> plu...
ancestors and self render and get
235,619
public function setConfigs ( array $ args ) { if ( ! is_array ( current ( $ args ) ) ) { $ args = [ $ this -> currentName => $ args ] ; } foreach ( $ args as $ key => $ item ) { if ( array_key_exists ( $ key , $ this -> configs ) ) { $ this -> configs [ $ key ] = array_merge ( $ this -> configs [ $ key ] , $ item ) ; }...
ADD 2D ARRAY
235,620
public function getEngine ( $ name = null ) { if ( is_null ( $ name ) ) { $ name = $ this -> getCurrentName ( ) ; } if ( array_key_exists ( $ name , $ this -> engines ) ) { return $ this -> engines [ $ name ] ; } if ( ! $ this -> hasConfig ( $ name ) ) { throw new \ InvalidArgumentException ( sprintf ( __ ( '%s DOES NO...
GET DATABASE ENGINE
235,621
public function make ( $ abstract ) { $ service = isset ( $ this -> services [ $ abstract ] ) ? $ this -> services [ $ abstract ] : $ this -> addNamespace ( $ abstract ) ; if ( is_callable ( $ service ) ) { return call_user_func_array ( $ service , [ $ this ] ) ; } if ( is_object ( $ service ) ) { return $ service ; } ...
Resolve the given type from the container . Allow unbound aliases that omit the root namespace i . e . Controller translates to GeminiLabs \ Castor \ Controller
235,622
protected function additionalSavingTasks ( Pg $ pg , $ simulate = false , array & $ ignoreList = array ( ) , $ action = self :: ACTION_OBJECT ) { $ repository = $ this -> recordManager -> entityManager -> getRepository ( $ this -> object -> class ) ; $ normality = $ repository -> normality ; if ( isset ( $ normality [ ...
Execute additional saving tasks .
235,623
static function camelize ( $ str ) { $ str = str_replace ( '_' , ' ' , $ str ) ; $ str = ucwords ( $ str ) ; $ str = str_replace ( ' ' , '' , $ str ) ; return lcfirst ( $ str ) ; }
Changes word format to camelize
235,624
static function studly ( $ str ) { $ str = str_replace ( '_' , ' ' , $ str ) ; $ str = ucwords ( $ str ) ; $ str = str_replace ( ' ' , '' , $ str ) ; return $ str ; }
Changes word format to studly
235,625
private function get ( ) { if ( $ this -> inPos < $ this -> inLength ) { $ c = $ this -> in [ $ this -> inPos ] ; ++ $ this -> inPos ; } else { return self :: EOF ; } if ( $ c === "\n" || $ c === self :: EOF || ord ( $ c ) >= self :: ORD_space ) { return $ c ; } if ( $ c === "\r" ) { return "\n" ; } return ' ' ; }
Get the next character from the input stream .
235,626
private function peek ( ) { return ( $ this -> inPos < $ this -> inLength ) ? $ this -> in [ $ this -> inPos ] : self :: EOF ; }
Get the next character from the input stream without gettng it .
235,627
function next ( ) { $ c = $ this -> get ( ) ; if ( $ c == '/' ) { switch ( $ this -> peek ( ) ) { case '/' : $ this -> inPos = strpos ( $ this -> in , "\n" , $ this -> inPos ) ; return $ this -> in [ $ this -> inPos ] ; case '*' : $ this -> inPos = strpos ( $ this -> in , "*/" , $ this -> inPos ) ; if ( $ this -> inPos...
Get the next character from the input stream excluding comments .
235,628
function action ( $ action ) { switch ( $ action ) { case self :: JSMIN_ACT_FULL : $ this -> put ( $ this -> theA ) ; case self :: JSMIN_ACT_BUF : $ tmpA = $ this -> theA = $ this -> theB ; if ( $ tmpA == '\'' || $ tmpA == '"' ) { $ pos = $ this -> inPos ; while ( true ) { $ pos = $ this -> getCloser ( $ this -> in , a...
Do something !
235,629
public function getControllerInstance ( $ class , $ namespace = '' ) { if ( isset ( $ this -> complement [ 'namespaces' ] ) ) { if ( isset ( $ this -> complement [ 'namespaces' ] [ $ namespace ] ) ) { $ namespace = $ this -> complement [ 'namespaces' ] [ $ namespace ] ; $ _class = $ namespace . $ class ; if ( class_exi...
Get complement controller instance .
235,630
private function setComplement ( $ complement ) { $ this -> getStates ( ) ; $ this -> setComplementParams ( $ complement ) ; $ state = $ this -> getState ( ) ; $ action = $ this -> getAction ( $ state ) ; $ this -> setAction ( $ action ) ; $ this -> setState ( $ state ) ; $ this -> getSettings ( ) ; $ states = [ 'activ...
Set complement .
235,631
private function setComplementParams ( $ complement ) { $ params = array_intersect_key ( array_flip ( self :: $ required ) , $ complement ) ; $ slug = explode ( '.' , basename ( $ complement [ 'config-file' ] ) ) ; $ default [ 'slug' ] = $ slug [ 0 ] ; $ complementType = self :: getType ( 'strtoupper' ) ; $ path = App ...
Check required params and set complement params .
235,632
private function getLanguage ( ) { $ wpLang = ( function_exists ( 'get_locale' ) ) ? get_locale ( ) : null ; $ browserLang = null ; if ( isset ( $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ) ) { $ browserLang = $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ; } return substr ( $ wpLang ? : $ browserLang ? : 'en' , 0 , 2 ) ; }
Gets the current locale .
235,633
private function setImage ( ) { $ slug = $ this -> complement [ 'slug' ] ; $ complementType = self :: getType ( 'strtoupper' ) ; $ complementPath = App :: $ complementType ( ) ; $ complementUrl = $ complementType . '_URL' ; $ complementUrl = App :: $ complementUrl ( ) ; $ file = 'public/images/' . $ slug . '.png' ; $ f...
Set image url .
235,634
private static function getType ( $ mode = 'strtolower' , $ plural = true ) { $ namespace = get_called_class ( ) ; $ class = explode ( '\\' , $ namespace ) ; $ complement = strtolower ( array_pop ( $ class ) . ( $ plural ? 's' : '' ) ) ; switch ( $ mode ) { case 'ucfirst' : return ucfirst ( $ complement ) ; case 'strto...
Get complement type .
235,635
private function addRoutes ( ) { if ( class_exists ( $ Router = 'Josantonius\Router\Router' ) ) { if ( isset ( $ this -> complement [ 'routes' ] ) ) { $ Router :: add ( $ this -> complement [ 'routes' ] ) ; } } }
Add complement routes if exists .
235,636
public function refreshAccessToken ( ) { $ newToken = $ this -> http -> requestAccessToken ( ) ; if ( ! is_null ( $ newToken ) ) { $ this -> config -> setAccessToken ( $ newToken ) ; $ this -> http = new Request ( $ this -> guzzle , $ this -> config , $ this -> climate ) ; if ( $ this -> config -> shouldStoreToken ( ) ...
Get a new access token
235,637
public static function wait ( string $ args ) : ? SymfonyProcess { $ process = new SymfonyProcess ( 'php ' . Accessor :: $ appRoot . 'craftsman ' . $ args ) ; $ process -> start ( ) ; $ process -> wait ( ) ; $ process -> stop ( ) ; return $ process ; }
Run and wait
235,638
public function createModule ( Module $ module ) { $ dst = $ this -> rootDir . '/../src/Terrific/Module/' . StringUtils :: camelize ( $ module -> getName ( ) ) ; if ( $ this -> toolbarMode === ToolbarListener :: DEMO ) { throw new \ Exception ( 'This action is not supported in demo mode' ) ; } else { if ( $ this -> mod...
Creates a Terrific Module
235,639
public function createSkin ( Skin $ skin ) { $ module = new Module ( ) ; $ module -> setName ( $ skin -> getModule ( ) ) ; $ module -> addSkin ( $ skin ) ; $ dst = $ this -> rootDir . '/../src/Terrific/Module/' . StringUtils :: camelize ( $ module -> getName ( ) ) ; if ( $ this -> toolbarMode === ToolbarListener :: DEM...
Creates a Terrific Skin
235,640
public function getModules ( ) { $ modules = array ( ) ; $ dir = $ this -> rootDir . '/../src/Terrific/Module/' ; $ finder = new Finder ( ) ; $ finder -> directories ( ) -> in ( $ dir ) -> depth ( '== 0' ) ; foreach ( $ finder as $ file ) { $ module = $ file -> getFilename ( ) ; $ modules [ $ module ] = $ this -> getMo...
Gets all existing Modules
235,641
public function getCount ( $ where = '' , $ variables = null ) { $ where = $ this -> formatWhereClause ( $ where ) ; $ response = $ this -> driver -> query ( "select count(*) as numberOfItems from " . $ this -> getTable ( ) . ' ' . $ where . ";" , $ variables ) ; if ( ! $ response -> count ( ) ) return 0 ; $ response =...
Return the number of items available in the table
235,642
protected function formatWhereClause ( $ where ) { if ( ! empty ( $ where ) ) { if ( stripos ( $ where , 'where' ) === false || stripos ( $ where , 'select' ) !== false ) { $ where = ' where ' . $ where ; } } return $ where ; }
Some simple checks for a where clause
235,643
public function fetchAll ( $ page , $ pagination , $ where ) { $ index = ceil ( ( $ page - 1 ) * $ pagination ) ; $ where = $ this -> formatWhereClause ( $ where ) ; $ sql = " select " . $ this -> getMappingAsSQL ( ) . " from " . $ this -> getTable ( ) . " " . $ where . " limit " . $ index . ',' . intval ( $ pa...
Actually fetch all the items with the given params
235,644
protected function fetchByColumn ( $ column , $ value ) { $ response = $ this -> driver -> query ( "select " . $ this -> getMappingAsSQL ( ) . " from " . $ this -> getTable ( ) . " where `" . $ column . "` = ? limit 1;" , array ( $ value ) , static :: DATA_OBJECT_CLASS ) ; return $ response -> row ( ) ; }
Do actual mysql query by specific criteria
235,645
public function getPrimaryKey ( $ tableAlias = '' ) { $ output = '' ; if ( ! empty ( $ tableAlias ) ) { $ output .= '`' . $ tableAlias . '`.' ; } $ output .= '`' . static :: ID_COLUMN . '`' ; return $ output ; }
Return primary key qualified or not
235,646
public function getColumnsAsSQL ( $ tableAlias = '' , $ columnPrefix = '' ) { if ( empty ( $ this -> mapping ) ) { return '*' ; } $ output = '' ; foreach ( $ this -> mapping as $ column => $ mappingField ) { if ( ! empty ( $ output ) ) { $ output .= ',' ; } if ( ! empty ( $ tableAlias ) ) { $ output .= '`' . $ tableAli...
Get raw columns as SQL with some prefix options
235,647
protected function resetMappingOptions ( ) { $ this -> mappingOptions = new \ stdClass ( ) ; $ this -> mappingOptions -> destructiveMapping = false ; $ this -> mappingOptions -> assignNonMappedColumns = true ; $ this -> mappingOptions -> fieldPrefix = '' ; $ this -> mappingOptions -> throwOnEmptyId = false ; $ this -> ...
Reset mapping options
235,648
public function setDestructiveMapping ( $ destructiveMapping ) { if ( empty ( $ this -> mappingOptions ) ) $ this -> resetMappingOptions ( ) ; $ this -> mappingOptions -> destructiveMapping = $ destructiveMapping ; return $ this ; }
Set destructive mapping option
235,649
public function setAssignNonMappedColumns ( $ assignNonMappedColumns ) { if ( empty ( $ this -> mappingOptions ) ) $ this -> resetMappingOptions ( ) ; $ this -> mappingOptions -> assignNonMappedColumns = $ assignNonMappedColumns ; return $ this ; }
Set flag for assigning non - mapped columns
235,650
public function setFieldPrefix ( $ fieldPrefix ) { if ( empty ( $ this -> mappingOptions ) ) $ this -> resetMappingOptions ( ) ; $ this -> mappingOptions -> fieldPrefix = $ fieldPrefix ; return $ this ; }
Set mapping option field prefix
235,651
public function setThrowIfEmptyId ( $ throwOnEmptyId ) { if ( empty ( $ this -> mappingOptions ) ) $ this -> resetMappingOptions ( ) ; $ this -> mappingOptions -> throwOnEmptyId = $ throwOnEmptyId ; return $ this ; }
Throw an exception if the main id doesn t get mapped?
235,652
protected function mapObject ( $ databaseResult ) { foreach ( $ databaseResult as $ column => $ value ) { if ( ! empty ( $ this -> mapping [ $ column ] ) ) { list ( $ variable , $ modifier ) = $ this -> splitVariableWithModifier ( $ this -> mapping [ $ column ] ) ; $ this -> $ variable = $ this -> getMappedValue ( $ da...
Map a single object to this instance
235,653
protected function splitVariableWithModifier ( $ column ) { $ modifier = false ; if ( strpos ( $ column , ':' ) !== false ) { return explode ( ':' , $ column ) ; } return [ $ column , false ] ; }
Splits variable with a modifier
235,654
protected function modifierDate ( $ input ) { if ( empty ( $ input ) ) return NULL ; if ( $ input instanceof \ DateTime ) return $ input ; try { $ output = new \ DateTime ( $ input ) ; $ output -> setTimeZone ( new \ DateTimeZone ( 'America/New_York' ) ) ; return $ output ; } catch ( \ Exception $ exception ) { if ( ! ...
Return a date time modified input
235,655
protected function modifierTimezone ( $ input ) { if ( $ input instanceof \ DateTimeZone ) return $ input ; try { $ output = new \ DateTimeZone ( $ input ) ; return $ output ; } catch ( \ Exception $ exception ) { if ( ! empty ( $ this -> log ) ) $ this -> log -> error ( "Failed to convert \\DateTimeZone object from st...
Return a timezone modified input
235,656
public function buildModel ( $ databaseResult = null ) { $ this -> resetMappingOptions ( ) ; if ( empty ( $ databaseResult ) ) return ; $ this -> mapObject ( $ databaseResult ) ; }
Map the object to itself
235,657
public function performMappingOnObject ( DataObject $ object ) { foreach ( $ this -> mapping as $ field => $ variable ) { $ modifier = false ; $ newField = $ variable ; if ( strpos ( $ variable , ':' ) !== false ) { list ( $ newField , $ modifier ) = explode ( ':' , $ variable ) ; $ object -> $ newField = $ this -> get...
Array walk function overridable
235,658
public function insertObject ( DataObject $ object , $ skipID = true ) { $ data = [ ] ; foreach ( $ this -> mapping as $ column => $ local ) { if ( $ skipID && ( $ column == static :: ID_COLUMN ) ) continue ; $ modifier = false ; if ( strpos ( $ local , ':' ) !== false ) { list ( $ local , $ modifier ) = explode ( ':' ...
Attempts to insert the object into the table
235,659
public function getUnmappedArray ( DataObject $ object ) { $ output = [ ] ; foreach ( $ this -> mapping as $ unmappedField => $ mappedField ) { if ( strpos ( $ mappedField , ':' ) !== false ) { list ( $ mappedField , $ modifier ) = explode ( ':' , $ mappedField ) ; } $ output [ $ unmappedField ] = $ object -> { $ mappe...
Return an array of an object as an unmapped aray useful for dumping defaults
235,660
public function findFilename ( $ name ) { $ logicalName = ( string ) $ name ; if ( isset ( $ this -> cache [ $ logicalName ] ) ) { return $ this -> cache [ $ logicalName ] ; } try { $ template = $ this -> parser -> parse ( $ name ) ; $ file = $ this -> locator -> locate ( $ template ) ; } catch ( \ Exception $ e ) { th...
Helper function for getting a template file name .
235,661
public function decryptMessage ( $ message ) { $ calgo = $ this -> config -> getCipherAlgorithm ( ) ; $ cmode = $ this -> config -> getCipherMode ( ) ; $ malgo = $ this -> config -> getHmacAlgorithm ( ) ; $ size = mcrypt_get_iv_size ( $ calgo , $ cmode ) ; $ keySize = mcrypt_get_key_size ( $ calgo , $ cmode ) ; $ hmacS...
Decrypts a message with auhtenticity check .
235,662
public function encryptMessage ( $ input ) { $ input = ( string ) $ input ; $ calgo = $ this -> config -> getCipherAlgorithm ( ) ; $ cmode = $ this -> config -> getCipherMode ( ) ; $ malgo = $ this -> config -> getHmacAlgorithm ( ) ; $ size = mcrypt_get_iv_size ( $ calgo , $ cmode ) ; $ keySize = mcrypt_get_key_size ( ...
Encrypts the given message and adds an authenticity code .
235,663
public function getColumnResult ( string $ columnName ) : FieldSearchResult { if ( ! $ this -> hasColumnResult ( $ columnName ) ) { throw new \ RuntimeException ( 'Could not find changed column named "' . $ columnName . '"' ) ; } return $ this -> fieldMatchList [ $ columnName ] ; }
Returns the column result matching the passed name .
235,664
public function load ( array $ configs , ContainerBuilder $ container ) { $ configuration = new Configuration ( ) ; $ processor = new Processor ( ) ; $ config = $ processor -> processConfiguration ( $ configuration , $ configs ) ; $ container -> setParameter ( 'white_october_pagerfanta.default_view' , $ config [ 'defau...
Responds to the white_october_pagerfanta configuration parameter .
235,665
public function getAttributeConditions ( $ attributeName , $ unindexablePredicates = false ) { return array_filter ( $ this -> parts , function ( Condition $ part ) use ( $ attributeName , $ unindexablePredicates ) { if ( $ part instanceof self ) { return $ part -> getAttributeConditions ( $ attributeName , $ unindexab...
Return all conditions of the specified type in this expression which use the indicated attribute as an operand .
235,666
public function boot ( ) { $ this -> loadConfig ( ) ; $ this -> registerExceptionHandler ( ) ; $ this -> registerProviders ( ) ; $ this -> registerAliases ( ) ; $ this -> registerScaraMasterSessionToken ( ) ; }
Handles registering Scara s pre - execution status .
235,667
private function loadConfig ( ) { $ this -> _config = new Configuration ( ) ; $ this -> _config -> from ( 'app' ) ; date_default_timezone_set ( $ this -> _config -> get ( 'timezone' ) ) ; }
Loads the application s main configuration .
235,668
private function registerControllers ( ) { $ this -> _controller = new Controller ( ) ; $ this -> _controller -> load ( $ this -> _router , $ this -> _config -> get ( 'basepath' ) ) ; }
Responsible for registering the app controllers .
235,669
private function registerScaraMasterSessionToken ( ) { $ s = SessionInitializer :: init ( ) ; $ h = new OpenSslHasher ( ) ; if ( ! $ s -> has ( 'SCARA_SESSION_TOKEN' ) ) { $ token = substr ( $ h -> tokenize ( $ h -> random_string ( 16 ) , time ( ) ) , 0 , 16 ) ; $ session = $ h -> tokenize ( $ token , hash ( 'sha256' ,...
Registers Scara s master session .
235,670
private function setUp ( $ class , Run $ run ) { if ( ! $ class ) { $ run -> writeOutput ( "Missing `class` parameter on {$this->jobModel->id} job" ) -> setResult ( Run :: RESULT_FAILED ) ; return false ; } if ( ! class_exists ( $ class ) ) { $ run -> writeOutput ( "$class does not exist" ) -> setResult ( Run :: RESULT...
Sets up an invokable class for a scheduled job run .
235,671
private function invoke ( callable $ job , Run $ run ) { try { ob_start ( ) ; $ ret = call_user_func ( $ job , $ run ) ; $ result = Run :: RESULT_SUCCEEDED ; if ( false === $ ret ) { $ result = Run :: RESULT_FAILED ; } return $ run -> writeOutput ( ob_get_clean ( ) ) -> setResult ( $ result ) ; } catch ( Exception $ e ...
Executes the actual job .
235,672
private function saveRun ( Run $ run ) { $ this -> jobModel -> last_ran = time ( ) ; $ this -> jobModel -> last_run_succeeded = $ run -> succeeded ( ) ; $ this -> jobModel -> last_run_output = $ run -> getOutput ( ) ; $ this -> jobModel -> save ( ) ; }
Saves the run attempt .
235,673
public static function format_backtrace ( $ backtrace ) { global $ CFG ; $ html = '' ; $ i = count ( $ backtrace ) ; foreach ( $ backtrace as $ trace ) { $ file = ( isset ( $ trace [ 'file' ] ) ) ? str_replace ( $ CFG -> base_absroot , '' , $ trace [ 'file' ] ) : 'unknown' ; $ line = 'Line: ' . ( ( isset ( $ trace [ 'l...
Format a backtrace for better display .
235,674
public static function error_handler ( $ errcode , $ errstr , $ errfile , $ errline , $ errcontext ) { throw new \ Exception ( $ errstr . ' in ' . $ errfile . ' on line ' . $ errline , $ errcode ) ; }
Handle PHP errors .
235,675
public static function write_error_html ( $ errtitle , $ errdetails , $ errcode , $ backtrace = null ) { global $ USR ; ?> <!DOCTYPE HTML> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title> <?php ...
For handle - able errors print out our custom error screen .
235,676
public function getDailyMotionId ( $ url ) { if ( preg_match ( '!^.+dailymotion\.com/(video|hub)/([^_]+)[^#]*(#video=([^_&]+))?|(dai\.ly/([^_]+))!' , $ url , $ m ) ) { if ( isset ( $ m [ 6 ] ) ) { return $ m [ 6 ] ; } if ( isset ( $ m [ 4 ] ) ) { return $ m [ 4 ] ; } return $ m [ 2 ] ; } return false ; }
Extracts the daily motion id from a daily motion url . Returns false if the url is not recognized as a daily motion url .
235,677
public static function display_debug ( $ obj ) { $ ptr = self :: get_debug_vars ( $ obj ) ; if ( $ obj instanceof Smarty ) { $ smarty = clone $ obj ; } else { $ smarty = clone $ obj -> smarty ; } $ _assigned_vars = $ ptr -> tpl_vars ; ksort ( $ _assigned_vars ) ; $ _config_vars = $ ptr -> config_vars ; ksort ( $ _confi...
Opens a window for the Smarty Debugging Consol and display the data
235,678
public function getDriver ( array $ mappingSource ) : DriverInterface { if ( \ array_key_exists ( 'driver' , $ mappingSource ) ) { $ driver = $ mappingSource [ 'driver' ] ; if ( ! $ driver instanceof DriverInterface ) { throw new DriverException ( \ sprintf ( 'Metadata mapping driver should be of the type %s, %s given'...
Get mapping driver .
235,679
protected function getDriverImplementation ( string $ type , array $ paths ) : DriverInterface { switch ( $ type ) { case DriverFactoryInterface :: DRIVER_ANNOTATION : return $ this -> getAnnotationDriver ( $ paths ) ; case DriverFactoryInterface :: DRIVER_PHP : return $ this -> getPhpDriver ( $ paths ) ; case DriverFa...
Get mapping driver implementation .
235,680
private static function _write ( $ type , $ message ) { $ log_path = Config :: get ( 'log.folder' , LOLLIPOP_STORAGE_LOG ) ; $ log_enable = Config :: get ( 'log.enable' , true ) ; $ log_hourly = Config :: get ( 'log.hourly' , false ) ; if ( ! is_dir ( $ log_path ) ) throw new \ Lollipop \ Exception \ Runtime ( 'Log fol...
Append to log file
235,681
public static function loadCsvToArray ( $ field , $ firstRowLabels = true ) { $ result = false ; if ( ! empty ( $ _FILES [ $ field ] [ 'tmp_name' ] ) ) { $ csv = fopen ( $ _FILES [ $ field ] [ 'tmp_name' ] , 'r' ) ; $ result = array ( ) ; if ( $ firstRowLabels ) { $ fields = fgetcsv ( $ csv ) ; } while ( $ csvRow = fge...
Load an uploaded CSV file into an associative array
235,682
public static function URLfromPath ( $ path , array $ vars = null , $ basePath = false ) { if ( $ vars === null ) { if ( php_sapi_name ( ) != 'cli' ) { $ vars = $ _SERVER ; } else { return false ; } } if ( $ basePath !== false && substr ( $ path , 0 , 1 ) !== '/' ) { $ basePath = rtrim ( $ basePath , '/' ) ; $ path = r...
Generate a URL from a path
235,683
public function invoke ( $ name , array $ args ) { $ signature = $ name . ':' . serialize ( $ args ) ; if ( ! isset ( $ this -> cache [ $ signature ] ) ) { $ this -> cache [ $ signature ] = call_user_func_array ( array ( $ this -> repository , $ name ) , $ args ) ; } return $ this -> cache [ $ signature ] ; }
Read results from cache or proxy to wrapped doctrine repository .
235,684
public function choice ( FormView $ choice ) { $ that = $ this ; if ( $ choice -> vars [ 'compound' ] ) { usort ( $ choice -> children , function ( FormView $ a , FormView $ b ) use ( $ that ) { return $ that -> compare ( $ a -> vars [ 'label' ] ? : $ a -> vars [ 'value' ] , $ b -> vars [ 'label' ] ? : $ b -> vars [ 'v...
Sort choice .
235,685
private function updateCheck ( $ name ) { $ filePath = Yii :: getPathOfAlias ( 'base.themes' ) . DS . $ name ; $ details = $ this -> actionDetails ( $ name ) ; if ( file_exists ( $ filePath . DS . 'VERSION' ) ) { $ version = file_get_contents ( $ filePath . DS . 'VERSION' ) ; if ( $ version != $ details [ 'latest-versi...
Checks if an update is necessary
235,686
public function actionUpdateCheck ( $ name = false ) { if ( $ name == false ) return false ; if ( defined ( 'CII_CONFIG' ) ) return $ this -> returnError ( 200 , Yii :: t ( 'Api.main' , 'Update is not required' ) , false ) ; if ( $ this -> updateCheck ( $ name ) ) return $ this -> returnError ( 200 , Yii :: t ( 'Api.ma...
Exposed action to check for an update
235,687
public function actionUpdate ( $ name = false ) { if ( $ name == false || defined ( 'CII_CONFIG' ) ) return false ; if ( $ this -> updateCheck ( $ name ) ) { if ( ! $ this -> actionInstall ( $ name ) ) return $ this -> returnError ( 500 , Yii :: t ( 'Api.main' , 'Update failed' ) , false ) ; } return $ this -> actionDe...
Performs an update
235,688
public function actionInstall ( $ name = false ) { if ( $ name == false || defined ( 'CII_CONFIG' ) ) return false ; $ filePath = Yii :: getPathOfAlias ( 'base.themes' ) . DS . $ name ; $ details = $ this -> actionDetails ( $ name ) ; if ( $ this -> actionIsInstalled ( $ name , true ) ) { if ( file_exists ( $ filePath ...
Installs and or updates a theme using the provided name
235,689
public function actionUninstall ( $ name = false ) { if ( $ name == false ) return false ; if ( $ name == 'default' ) throw new CHttpException ( 400 , Yii :: t ( 'Api.theme' , 'You cannot uninstall the default theme.' ) ) ; if ( ! $ this -> actionIsInstalled ( $ name ) ) return false ; $ installedThemes = $ this -> act...
Uninstalls a theme by name
235,690
public function actionList ( ) { if ( defined ( 'CII_CONFIG' ) ) return false ; $ response = Yii :: app ( ) -> cache -> get ( 'CiiMS::API::Themes::Available' ) ; if ( $ response === false ) { $ url = 'https://themes.ciims.io/index.json' ; $ curl = new \ Curl \ Curl ; $ response = $ curl -> get ( $ url ) ; if ( $ curl -...
Lists ciims - themes that are available for download via
235,691
public function actionDetails ( $ name = false ) { if ( $ name == false ) throw new CHttpException ( 400 , Yii :: t ( 'Api.Theme' , 'Missing theme name' ) ) ; $ data = Yii :: app ( ) -> cache -> get ( 'CiiMS::API::Themes::' . $ name ) ; if ( $ data === false ) { $ url = 'https://packagist.org/packages/ciims-themes/' . ...
Retrieves the details about a particular theme
235,692
public function actionCallbackPost ( $ theme = NULL , $ method = NULL ) { $ this -> callback ( $ theme , $ method , $ _POST ) ; }
Allows themes to have their own dedicated callback resources for POST
235,693
private function callback ( $ theme , $ method , $ data ) { if ( $ theme == NULL ) throw new CHttpException ( 400 , Yii :: t ( 'Api.Theme' , 'Missing Theme' ) ) ; if ( $ method == NULL ) throw new CHttpException ( 400 , Yii :: t ( 'Api.Theme' , 'Method name is missing' ) ) ; Yii :: import ( 'base.themes.' . $ theme . '...
Callback method for actionCallback and actionCallbackPost
235,694
public function save ( $ name , Config $ config ) { $ path = $ this -> _getPath ( $ name ) ; $ data = $ config -> valueOf ( ) ; file_put_contents ( $ path , serialize ( $ data ) ) ; return true ; }
Save config data
235,695
public function delete ( $ name ) { $ path = $ this -> _getPath ( $ name ) ; if ( file_exists ( $ path ) ) { $ result = @ unlink ( $ path ) ; } else { $ result = false ; } return $ result ; }
Delete config data
235,696
public static function encode ( $ data , $ forceObject = false ) { return @ json_encode ( $ data , JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | ( $ forceObject ? JSON_FORCE_OBJECT : 0 ) ) ; }
Encode the given data into a JSON string .
235,697
public static function decode ( $ json , $ assoc = false , $ maxDepth = 512 ) { $ result = @ json_decode ( $ json , $ assoc , $ maxDepth ) ; if ( $ result === NULL ) { switch ( $ error = json_last_error ( ) ) { case JSON_ERROR_NONE : return NULL ; case JSON_ERROR_CTRL_CHAR : throw new JsonUnserializationException ( 'An...
Decode the given JSON string into a PHP data structure .
235,698
public function get ( $ index ) { return array_slice ( $ this -> items , $ index * $ this -> itemsPerPage , $ this -> itemsPerPage ) ; }
Returns the items on the given page number .
235,699
public function useName ( $ name ) { if ( empty ( $ name ) ) { throw new \ Exception ( 'Given name is empty!' ) ; } if ( ! isset ( $ _FILES [ $ name ] ) ) { throw new \ Exception ( 'Given name not exists in $_FILES var!' ) ; } $ this -> data = $ _FILES [ $ name ] ; return $ this ; }
Use name as default in File s methods .