idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
14,100
public function outputView ( ) { if ( ! $ this -> view ) { return '' ; } if ( ! isset ( self :: $ views [ $ this -> view ] ) ) { if ( ! class_exists ( $ this -> view ) ) { $ this -> view = str_replace ( '_' , '' , $ this -> view ) ; } $ view = new $ this -> view ( $ this ) ; $ view -> setUp ( ) ; self :: $ views [ $ th...
Gets HTML code from view passing all data generated within controller
14,101
public static function countRelatedElements ( Model $ model , $ type = null ) { if ( $ model -> getType ( ) == $ model :: TYPE_START ) { if ( $ type === null ) { $ column = 'bootstrap_parentId' ; $ values = $ model -> id ; } else { $ column = array ( 'bootstrap_parentId=?' , 'type=?' ) ; $ values = array ( $ model -> i...
count related elements optionally limited by type
14,102
public static function findPreviousElement ( Model $ model , $ type = null ) { if ( $ type === null ) { $ type = $ model -> getType ( ) ; } $ column = array ( 'pid=?' , 'ptable=?' , 'type=?' , 'sorting<?' ) ; $ values = array ( $ model -> pid , $ model -> ptable , $ model -> getTypeName ( $ type ) , $ model -> sorting ...
try to find previous element of same type or specified type
14,103
public function actionAdd ( $ productId ) { if ( ! empty ( $ productId ) ) { if ( ! Yii :: $ app -> user -> isGuest ) { $ model = new FavoriteProduct ( ) ; $ model -> product_id = $ productId ; $ model -> user_id = Yii :: $ app -> user -> id ; if ( $ model -> save ( ) ) { if ( Yii :: $ app -> request -> isAjax ) { retu...
Adds product to list of favorites .
14,104
public function actionRemove ( $ productId ) { if ( ! empty ( $ productId ) ) { if ( ! Yii :: $ app -> user -> isGuest ) { $ model = FavoriteProduct :: find ( ) -> where ( [ 'product_id' => $ productId , 'user_id' => Yii :: $ app -> user -> id ] ) -> one ( ) ; if ( ! empty ( $ model ) ) { $ model -> delete ( ) ; if ( Y...
Removes product from list of favorites .
14,105
public function actionList ( ) { $ searchModel = new SearchFavoriteProduct ( ) ; $ dataProvider = $ searchModel -> search ( Yii :: $ app -> request -> queryParams ) ; return $ this -> render ( 'list' , [ 'searchModel' => $ searchModel , 'dataProvider' => $ dataProvider , ] ) ; }
Lists all FavoriteProduct models .
14,106
protected function recountRatingOfAllModelTypes ( ) { $ rateableTypes = app ( RatingModelContract :: class ) -> select ( [ 'rateable_type' ] ) -> groupBy ( 'rateable_type' ) -> get ( ) ; foreach ( $ rateableTypes as $ rating ) { $ this -> recountRatingOfModelType ( $ rating -> rateable_type ) ; } }
Recount rating of all model types .
14,107
protected function recountRatingOfModelType ( $ modelType ) { $ modelType = $ this -> normalizeModelType ( $ modelType ) ; $ counters = $ this -> service -> fetchRatesCounters ( $ modelType ) ; $ this -> service -> removeRatingTotalOfType ( $ modelType ) ; DB :: table ( app ( RatingTotalModelContract :: class ) -> getT...
Recount rating of model type .
14,108
protected function normalizeModelType ( $ modelType ) { $ morphMap = Relation :: morphMap ( ) ; if ( class_exists ( $ modelType ) ) { $ model = new $ modelType ; $ modelType = $ model -> getMorphClass ( ) ; } else { if ( ! isset ( $ morphMap [ $ modelType ] ) ) { throw new ModelInvalidException ( "[$modelType] class an...
Normalize rateable model type .
14,109
public function actionList ( int $ productId , int $ languageId ) { $ product = Product :: findOne ( $ productId ) ; $ products = Product :: find ( ) -> joinWith ( 'translations' ) -> orderBy ( 'title' ) -> all ( ) ; $ relatedProducts = $ product -> relatedProducts ; $ newRelatedProduct = new RelatedProduct ( ) ; $ sel...
Shows all related products for current product
14,110
public function actionRemove ( int $ id ) { RelatedProduct :: deleteAll ( [ 'id' => $ id ] ) ; return $ this -> redirect ( \ Yii :: $ app -> request -> referrer ) ; }
Removes relation product
14,111
public function dec ( $ id , $ value = 1 ) { if ( ! $ this -> connectionCheckStatus ) { $ this -> addServer ( ) ; } $ id = $ this -> prepareId ( $ id ) ; $ result = $ this -> getClient ( ) -> decrement ( $ id , $ value ) ; if ( $ result === false && $ this -> operationsExceptions ) { throw new OperationFailed ( 'Decrem...
Decrement the numeric data in the cache
14,112
protected function prepareId ( $ id ) { if ( ! is_scalar ( $ id ) ) { $ id = json_encode ( $ id ) ; if ( isset ( $ id [ 33 ] ) ) { $ id = md5 ( $ id ) ; } } if ( $ this -> namespace === null ) { return $ id ; } return $ this -> namespace . '_' . $ id ; }
Prepare the ID
14,113
public function addServer ( ) { $ argsRaw = func_get_args ( ) ; if ( isset ( $ argsRaw [ 0 ] ) && is_array ( $ argsRaw [ 0 ] ) ) { $ args = self :: $ defaultServerArgs ; foreach ( $ argsRaw [ 0 ] as $ param => $ value ) { if ( isset ( self :: $ serverParamsToArgs [ $ param ] ) ) { $ args [ self :: $ serverParamsToArgs ...
Add the server to the client
14,114
public function setClient ( MemcacheClient $ client ) { $ this -> memcacheClient = $ client ; $ this -> connectionCheckStatus = ( @ $ client -> getStats ( ) !== false ) ; }
Set the client
14,115
public function hasRoutableTemplates ( ) { $ this -> buildTemplateIndex ( ) ; $ routable = false ; foreach ( $ this -> templateIndex as $ name => $ template ) { if ( ( $ name !== self :: INDEX_TEMPLATE ) && ( $ name !== self :: NOTFOUND_TEMPLATE ) ) { $ routable = true ; break ; } } return ( $ routable ) ; }
hasRoutableTemplates Determine if routable templates other than home and 404 exist .
14,116
public function resolveTemplate ( $ request_string ) { $ this -> debug ( sprintf ( 'resolveTemplate: Resolving %s.' , $ request_string ) ) ; $ template = false ; $ this -> buildTemplateIndex ( ) ; if ( false !== strpos ( $ request_string , '?' ) ) { $ request_string = substr ( $ request_string , 0 , strpos ( $ request_...
resolveTemplate Resolve a request type string to a template or false if none found .
14,117
protected function buildTemplateIndex ( ) { if ( false === $ this -> templateIndexBuilt ) { foreach ( $ this -> templatePath as $ path ) { $ dir = new \ RecursiveDirectoryIterator ( $ path ) ; $ it = new \ RecursiveIteratorIterator ( $ dir ) ; foreach ( $ it as $ template_file ) { if ( $ this -> validateTemplate ( $ te...
buildTemplateIndex Build an index array of the routable templates .
14,118
protected function validateTemplate ( $ template_file ) { $ is_valid = false ; if ( ! $ template_file instanceof \ SplFileInfo ) { $ template_file = new \ SplFileInfo ( $ template_file ) ; } if ( $ template_file -> isFile ( ) && $ template_file -> isReadable ( ) && ( 'html' === $ template_file -> getExtension ( ) ) ) {...
validateTemplate Validate a template as readable and routable .
14,119
protected function validateTemplatePath ( ) { array_walk ( $ this -> templatePath , function ( $ val , $ key ) { if ( ! is_dir ( $ val ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid template path: %s' , $ val ) ) ; } } ) ; }
validateTemplatePath Validate the template directories .
14,120
public function registerAutoload ( $ basePath , $ prefix = '' , $ relative = true ) { $ path = $ relative ? $ this -> basePath . '/' . $ basePath : $ basePath ; Autoloader :: getInstance ( ) -> registerAutoload ( $ path , $ prefix ) ; }
PSR - 4 autoloader path register
14,121
public function putContents ( $ file , $ contents , $ flag = null , $ context = null ) { $ file = $ this -> basePath . '/' . ltrim ( $ file , '/\\' ) ; return file_put_contents ( $ file , $ contents , $ flag , $ context ) ; }
Put the content of file of the path
14,122
public function register ( $ name , $ path , $ absolute = false ) { if ( $ path instanceof \ Exedra \ Path ) return $ this -> pathRegistry [ $ name ] = $ path ; $ path = $ absolute ? $ path : $ this -> basePath . '/' . ltrim ( $ path , '/\\' ) ; $ this -> pathRegistry [ $ name ] = new static ( $ path ) ; return $ this ...
Register a new path for the given name and path
14,123
public function format ( $ value , $ params = null , $ locale = null ) { if ( ! isset ( $ params [ 'primary' ] ) ) { return $ this -> getFormatter ( $ locale ) -> format ( $ value ) ; } if ( $ params [ 'primary' ] === 'day' ) { return $ this -> getFormatterDay ( $ locale ) -> format ( $ value ) ; } if ( $ params [ 'pri...
Format the date
14,124
protected function getFormatter ( $ locale ) { if ( ! isset ( $ this -> formatters [ $ locale ] ) ) { $ this -> formatters [ $ locale ] = new IntlDateFormatter ( $ locale , IntlDateFormatter :: SHORT , IntlDateFormatter :: SHORT ) ; } return $ this -> formatters [ $ locale ] ; }
Get the date and time formatter
14,125
protected function getFormatterDay ( $ locale ) { if ( ! isset ( $ this -> formattersDay [ $ locale ] ) ) { $ this -> formattersDay [ $ locale ] = new IntlDateFormatter ( $ locale , IntlDateFormatter :: MEDIUM , IntlDateFormatter :: NONE ) ; } return $ this -> formattersDay [ $ locale ] ; }
Get the date only formatter
14,126
protected function getFormatterTime ( $ locale ) { if ( ! isset ( $ this -> formattersTime [ $ locale ] ) ) { $ this -> formattersTime [ $ locale ] = new IntlDateFormatter ( $ locale , IntlDateFormatter :: NONE , IntlDateFormatter :: MEDIUM ) ; } return $ this -> formattersTime [ $ locale ] ; }
Get the time only formatter
14,127
public function composeXls ( array $ data = [ ] , int $ status = 200 , array $ config = [ ] ) : SymfonyResponse { return $ this -> composeExcel ( $ data , $ config , Exporter :: XLS ) ; }
Compose XLS .
14,128
public function composeXlsx ( array $ data = [ ] , int $ status = 200 , array $ config = [ ] ) : SymfonyResponse { return $ this -> composeExcel ( $ data , $ config , Exporter :: XLSX ) ; }
Compose XLSX .
14,129
protected function composeExcel ( array $ data , array $ config , string $ writerType ) : SymfonyResponse { $ filename = $ config [ 'filename' ] ?? 'export' ; return $ this -> convertToExcel ( $ data , $ config ) -> exportExcel ( $ filename , $ writerType ) ; }
Compose excel .
14,130
public function getFullNameAttribute ( ) { $ names = array_filter ( [ $ this -> first_name , $ this -> middle_name , $ this -> last_name , ] ) ; if ( empty ( $ names ) ) { return null ; } return implode ( ' ' , $ names ) ; }
Get the user s full name based on the available names .
14,131
public function homeAction ( TokenStorageInterface $ token_storage , MembershipProviderInterface $ membership_provider ) : Response { $ user = $ token_storage -> getToken ( ) -> getUser ( ) ; $ memberships = $ membership_provider -> loadActiveMembershipsByUser ( $ user ) ; return new Response ( $ this -> templating -> ...
Shows a list of productions the current user has access to .
14,132
static function cleanBuffers ( ? int $ targetLevel = null , bool $ catchExceptions = false ) : bool { $ level = 0 ; $ stopLevel = $ targetLevel ?? 0 ; foreach ( self :: iterateBufferLevels ( PHP_OUTPUT_HANDLER_CLEANABLE ) as $ level ) { if ( $ level <= $ stopLevel ) { break ; } try { ob_end_clean ( ) ; } catch ( \ Thro...
Attempt to clean output buffers
14,133
static function captureBuffers ( ? int $ targetLevel = null , bool $ catchExceptions = false ) : string { $ output = '' ; $ stopLevel = $ targetLevel ?? 0 ; foreach ( self :: iterateBufferLevels ( PHP_OUTPUT_HANDLER_CLEANABLE ) as $ level ) { if ( $ level <= $ stopLevel ) { break ; } try { $ output = ob_get_clean ( ) ....
Attempt to capture output buffers
14,134
static function replaceHeaders ( array $ newHeaders ) : bool { if ( ! headers_sent ( ) ) { header_remove ( ) ; foreach ( $ newHeaders as $ header ) { header ( $ header ) ; } return true ; } return false ; }
Attempt to replace headers
14,135
public function addRoutes ( array $ routes ) { foreach ( $ routes as $ name => $ routeData ) $ this -> addRoute ( $ this -> factory -> createRoute ( $ this , $ name , $ routeData ) ) ; return $ this ; }
Add routes by the given array .
14,136
public function addOnRoute ( $ name , array $ routes ) { $ route = $ this -> findRoute ( $ name ) ; if ( $ route -> hasSubroutes ( ) ) $ route -> getSubroutes ( ) -> addRoutes ( $ routes ) ; else $ route -> setSubroutes ( $ routes ) ; return $ this ; }
Add subroutes on other route .
14,137
public function addRoute ( Route $ route ) { $ this -> routes [ $ route -> getName ( ) ] = $ route ; $ this -> storage [ ] = $ route ; return $ this ; }
Add route to this group .
14,138
public function findByRequest ( ServerRequestInterface $ request ) { $ result = $ this -> findRouteByRequest ( $ request , trim ( $ request -> getUri ( ) -> getPath ( ) , '/' ) ) ; if ( ! $ result [ 'route' ] ) throw new RouteNotFoundException ( 'Route for request ' . $ request -> getMethod ( ) . ' ' . $ request -> get...
Make a finding by \ Exedra \ Http \ Request
14,139
public function each ( \ Closure $ closure , $ deep = false ) { foreach ( $ this -> storage as $ route ) { $ result = $ closure ( $ route ) ; if ( $ result !== null ) return $ result ; if ( $ route -> hasSubroutes ( ) && $ deep ) { $ result = $ route -> getSubroutes ( ) -> each ( $ closure , true ) ; if ( $ result !== ...
Loop the routes within this routing group Break on other closure result not equal to null
14,140
protected function findRouteRecursively ( $ routeName ) { if ( is_string ( $ routeName ) ) { if ( isset ( $ this -> aliasIndices [ $ routeName ] ) ) { $ routeName = $ this -> aliasIndices [ $ routeName ] ; } else { foreach ( $ this -> groupAliasIndices as $ alias => $ name ) { if ( strpos ( $ routeName , $ alias ) === ...
A recursive search of route given by an absolute search string relative to this group
14,141
public function findRouteByTag ( $ tag ) { $ route = $ this -> each ( function ( Route $ route ) use ( $ tag ) { if ( $ route -> hasProperty ( 'tag' ) && $ route -> getProperty ( 'tag' ) == $ tag ) return $ route ; } , true ) ; return $ route ? : null ; }
Find route by given tag
14,142
protected function findRouteByRequest ( ServerRequestInterface $ request , $ groupUriPath , array $ passedParameters = array ( ) ) { foreach ( $ this -> storage as $ route ) { $ result = $ route -> match ( $ request , $ groupUriPath ) ; $ remainingPath = $ route -> getRemainingPath ( $ groupUriPath ) ; $ hasSubroutes =...
A recursivable functionality to find route under this routing group by the given request instance .
14,143
public function getRootGroup ( ) { if ( ! $ this -> route ) return $ this ; $ group = $ this -> route -> getGroup ( ) ; return $ group -> getRootGroup ( ) ; }
Recusively get the uppermost Routing \ Group
14,144
public function offsetGet ( $ name ) { if ( isset ( $ this -> routes [ $ name ] ) ) return $ this -> routes [ $ name ] ; $ route = $ this -> factory -> createRoute ( $ this , $ name , array ( ) ) ; $ this -> addRoute ( $ route ) ; return $ this -> routes [ $ name ] = $ route ; }
An array access get to conveniently create an empty route with the optional name
14,145
public function method ( $ method = null , $ path = '/' ) { $ parameters = array ( ) ; $ parameters [ 'path' ] = $ path ; if ( $ method ) $ parameters [ 'method' ] = $ method ; $ route = $ this -> factory -> createRoute ( $ this , null , $ parameters ) ; $ this -> addRoute ( $ route ) ; return $ route ; }
Create a route by given methods
14,146
public function tag ( $ tag ) { $ route = $ this -> factory -> createRoute ( $ this , null , array ( ) ) ; $ this -> addRoute ( $ route ) ; return $ route -> tag ( $ tag ) ; }
Create an empty route with the given tag
14,147
public function addRouteAlias ( $ routeName , $ alias ) { if ( is_array ( $ alias ) ) foreach ( $ alias as $ item ) $ this -> aliasIndices [ $ item ] = $ routeName ; else $ this -> aliasIndices [ $ alias ] = $ routeName ; return $ this ; }
Set alias for given route
14,148
public function addGroupAlias ( $ groupName , $ alias ) { if ( is_array ( $ alias ) ) foreach ( $ alias as $ item ) $ this -> groupAliasIndices [ $ item ] = $ groupName ; else $ this -> groupAliasIndices [ $ alias ] = $ groupName ; return $ this ; }
Set alias for given group
14,149
public function addAlias ( $ routeName , $ alias ) { if ( is_array ( $ alias ) ) foreach ( $ alias as $ item ) $ this -> aliasIndices [ $ item ] = $ routeName ; else $ this -> aliasIndices [ $ alias ] = $ routeName ; return $ this ; }
Use addRouteAlias instead
14,150
protected function initializeServices ( ) { $ this -> services [ 'route' ] = $ this -> finding -> getRoute ( ) ; $ this -> params = $ this -> finding -> getParameters ( ) ; $ this -> services [ 'request' ] = $ this -> finding -> getRequest ( ) ; }
Initialize execution services
14,151
protected function setUp ( ) { $ this -> services [ 'service' ] -> register ( array ( 'path' => function ( Context $ context ) { return $ context -> app -> path ; } , 'config' => function ( Context $ context ) { return clone $ context -> app -> config ; } , 'url' => function ( Context $ context ) { $ urlFactory = $ con...
Setup dependency registry
14,152
public function params ( array $ keys = array ( ) , $ onlyExistingParams = false ) { if ( count ( $ keys ) == 0 ) return $ this -> params ; $ params = array ( ) ; foreach ( $ keys as $ key ) { $ key = trim ( $ key ) ; if ( $ onlyExistingParams && isset ( $ this -> params [ $ key ] ) ) $ params [ $ key ] = $ this -> par...
Get params by the given list of keys
14,153
public function baseRoute ( $ route ) { if ( strpos ( $ route , '@' ) === 0 ) { $ route = substr ( $ route , 1 , strlen ( $ route ) - 1 ) ; } else { $ baseRoute = $ this -> route -> getParentRouteName ( ) ; $ route = $ baseRoute ? $ baseRoute . '.' . $ route : $ route ; } return $ route ; }
Base the given route . Or return an absolute route if absolute character was given at the beginning of the given string .
14,154
public function forward ( $ route , array $ args = array ( ) ) { $ route = $ this -> baseRoute ( $ route ) ; return $ this -> app -> execute ( $ route , $ args , $ this -> request ) ; }
Forward current request to the given route
14,155
public function execute ( $ route , array $ parameters = array ( ) , \ Exedra \ Http \ ServerRequest $ request = null ) { $ route = $ this -> baseRoute ( $ route ) ; $ request = $ request ? : $ this -> request ; return $ this -> app -> execute ( $ route , $ parameters , $ request ) ; }
Execute a scope based route
14,156
public function finalize ( ) { $ context = $ this ; while ( true ) { $ body = $ context -> response -> getBody ( ) ; if ( $ body instanceof \ Exedra \ Runtime \ Context ) $ context = $ body ; else break ; } return $ context ; }
Retrieve the actual execution instance
14,157
public function DeleteMsg ( $ id , Request $ request ) { $ msg = Ajaxis :: BtDeleting ( 'Warning!!' , 'Would you like to remove This?' , '/setting/' . $ id . '/delete/' ) ; if ( $ request -> ajax ( ) ) { return $ msg ; } }
Delete confirmation message by Ajaxis .
14,158
protected function createResult ( array & $ data , $ type = null ) { if ( $ type === null ) { $ type = $ this -> getResultType ( ) ; } if ( $ type & self :: RESULT_ARRAY ) { return $ data ; } if ( $ type & self :: RESULT_OBJECT ) { return ( object ) $ data ; } if ( $ type & self :: RESULT_MODEL ) { return $ this -> cre...
Create the result
14,159
protected function createResultset ( & $ data , $ type = null , $ primaryId = null ) { if ( $ type === null ) { $ type = $ this -> getResultType ( ) ; } if ( $ type & self :: RESULTSET_ARRAY ) { if ( $ data instanceof Traversable ) { $ data = iterator_to_array ( $ data ) ; } if ( $ type & ( self :: RESULT_ARRAY | self ...
Create the resultset
14,160
protected function createIterator ( Traversable $ sourceIterator ) { $ iterator = new Iterator ( $ sourceIterator , $ this -> getModelClass ( ) ) ; $ iterator -> setDatagate ( $ this ) ; if ( $ this -> hasLocator ( ) ) { $ iterator -> setLocator ( $ this -> getLocator ( ) ) ; } return $ iterator ; }
Create the iterator
14,161
public function create ( array & $ data = null ) { $ modelClass = $ this -> getModelClass ( ) ; $ model = $ modelClass :: factory ( $ data ) ; $ model -> setDatagate ( $ this ) ; if ( $ this -> hasLocator ( ) ) { $ model -> setLocator ( $ this -> getLocator ( ) ) ; } if ( empty ( $ data ) ) { $ model -> forceInsert ( )...
Create a new model empty or with the supplied data
14,162
public function createCollection ( array & $ data = null , $ primaryId = null ) { $ collectionClass = $ this -> getCollectionClass ( ) ; $ modelClass = $ this -> getModelClass ( ) ; if ( $ primaryId === null ) { $ primaryId = $ this -> getPrimaryName ( ) ; } if ( ! empty ( $ data ) || $ primaryId !== null ) { $ validat...
Create a new collection empty or with the supplied data
14,163
public function save ( DatagateAwareInterface $ model , array $ options = [ ] ) { if ( $ model -> isEmpty ( ) ) { throw new Exceptions \ OperationError ( 'Model has no data' ) ; } if ( $ model instanceof Model ) { return $ this -> saveModel ( $ model , $ options ) ; } if ( $ model instanceof Collection ) { return $ thi...
Save the model or the collection of the models
14,164
public function remove ( DatagateAwareInterface $ model , array $ options = [ ] ) { if ( $ model -> isEmpty ( ) ) { throw new Exceptions \ OperationError ( 'Model has no data' ) ; } if ( $ model instanceof Model ) { return $ this -> removeModel ( $ model , $ options ) ; } if ( $ model instanceof Collection ) { return $...
Remove the record or the many of records by the model or the collection of the models
14,165
public function getModelClass ( ) { if ( $ this -> model === null ) { $ introspection = $ this -> getIntrospectiveData ( ) ; $ modelBase = $ introspection -> name . self :: MODEL_POSTFIX ; $ modelPath = $ introspection -> dirname . DIRECTORY_SEPARATOR . $ modelBase . '.' . $ introspection -> extension ; $ this -> model...
Get model s class
14,166
public function getTableName ( ) { if ( $ this -> name === null ) { $ this -> name = lcfirst ( $ this -> getIntrospectiveData ( ) -> name ) ; } return $ this -> name ; }
Get the name of the table or collection
14,167
public function setPrimaryName ( $ primary ) { if ( is_string ( $ primary ) || is_array ( $ primary ) ) { $ this -> primary = $ primary ; return ; } throw new Exceptions \ InvalidOption ( 'Name of primary identity must be a string or an array, "' . gettype ( $ primary ) . '" was given' ) ; }
Set the name of the primary identity
14,168
public function getResultType ( ) { if ( $ this -> result === null ) { $ this -> result = self :: RESULTSET_COLLECTION | self :: RESULT_MODEL ; } return $ this -> result ; }
Get the type of an item of a data
14,169
protected function getIntrospectiveData ( ) { if ( $ this -> _introspectiveData === null ) { $ reflection = new ReflectionObject ( $ this ) ; $ data = ( object ) pathinfo ( $ reflection -> getFileName ( ) ) ; $ data -> namespace = $ reflection -> getNamespaceName ( ) ; $ data -> class = $ reflection -> getShortName ( )...
Get the introspective data
14,170
public function assemble ( ) { $ hashdata = '' ; $ linker = new Linker ( ) ; $ linker -> setOutputPath ( $ this -> getPath ( ) ) ; foreach ( $ this -> resources as $ resource ) { $ path = $ resource -> getPath ( ) ; $ hashdata .= $ path ; $ linker -> append ( $ path ) ; } $ hash = substr ( md5 ( $ hashdata ) , 24 ) ; $...
Assemble the package
14,171
protected function loadMigrations ( ) { $ this -> loadMigrationsFrom ( __DIR__ . '/../../../database/migrations' ) ; if ( $ this -> app [ 'config' ] -> get ( 'jumpgate.users.enable_social' ) ) { $ this -> loadMigrationsFrom ( __DIR__ . '/../../../database/social_migrations' ) ; } }
Load the migrations .
14,172
private function loadPublishable ( ) { $ publishDirectory = __DIR__ . '/../../../publish/' ; $ this -> publishes ( [ $ publishDirectory . 'Commands/UserDatabase.php' => app_path ( 'Console/Commands/JumpGate/UserDatabase.php' ) , $ publishDirectory . 'Http/Composers/AdminSidebar.php' => app_path ( 'Http/Composers/AdminS...
Add any extra publishable files to the site .
14,173
public function create ( int $ width , int $ height , bool $ true_color = true ) : bool { $ this -> image_width = $ width ; $ this -> image_height = $ height ; if ( ! $ this -> haveEnoughMemoryToOpenAndProcess ( ) ) { throw new RuntimeException ( 'Empty can not be created.' ) ; } if ( $ true_color ) { $ img = imagecrea...
Create empty image to work with used for creation from non - source
14,174
private function _resizeFit ( int $ width , int $ height , bool $ resample ) { $ this -> check ( ) ; $ src_w = $ this -> image_width ; $ src_h = $ this -> image_height ; $ k = ( ( $ src_w / $ src_h ) > ( $ width / $ height ) ? $ src_h / $ height : $ src_w / $ width ) ; $ resW = ( int ) round ( $ src_w / $ k ) ; $ resH ...
Resize fit with crop of redundant part
14,175
static protected function parse ( $ commandString , $ options = array ( ) ) { $ members = array_filter ( explode ( ' ' , $ commandString ) ) ; if ( ! empty ( $ members ) ) { $ commandName = array_shift ( $ members ) ; return new Command ( $ commandName , $ members , $ options ) ; } return new NullCommand ( ) ; }
Parse a command from a string representation and return the resulting object . If no valid command is found a NullCommand will be returned .
14,176
protected function _run ( $ input ) { $ this -> _output = '' ; $ this -> _errorOutput = '' ; $ descriptors = array ( 0 => array ( 'pipe' , 'r' ) , 1 => array ( 'pipe' , 'w' ) , 2 => array ( 'pipe' , 'w' ) , ) ; $ pipes = array ( ) ; $ childProcess = proc_open ( $ this -> toCommandString ( ) , $ descriptors , $ pipes ) ...
Actually run this command and its piped commands chain if applicable . Return the exit code for such execution .
14,177
public function toCommandString ( $ includePiped = false ) { $ command = $ this -> getName ( ) ; if ( ! $ this -> getArguments ( ) -> isEmpty ( ) ) { $ args = array ( ) ; $ delimiter = $ this -> getOption ( 'delimiter' , self :: DEFAULT_DELIMITER ) ; foreach ( $ this -> getArguments ( ) -> getAll ( ) as $ key => $ valu...
Get a string representation of this command with its arguments as if it would be written in a command - line interface when run .
14,178
protected function getClass ( ) { $ class = new \ ReflectionClass ( get_class ( $ this ) ) ; return [ 'name' => $ class -> getShortName ( ) , 'path' => $ class -> getFileName ( ) , 'resources' => dirname ( dirname ( $ class -> getFileName ( ) ) ) . S . 'Resources' , ] ; }
Retrieve class details .
14,179
public function columns ( $ columns ) { foreach ( $ columns as $ property => $ definition ) { if ( is_bool ( $ definition ) ) { $ this -> _properties [ $ property ] = $ definition ; continue ; } $ this -> addAccumulator ( $ property , $ definition ) ; } return $ this ; }
Set the properties list
14,180
protected function addAccumulator ( $ group , $ definition ) { $ definition = trim ( $ definition ) ; if ( ! preg_match ( '/^([a-z]+)\s*\(\s*(.+)\s*\)$/i' , $ definition , $ matches ) ) { throw new Exceptions \ InvalidDefinition ( 'Invalid definition: "' . $ definition . '"' ) ; } $ function = strtolower ( trim ( $ mat...
Add accumulator to the group
14,181
public function where ( $ condition , $ value = null , $ type = null ) { if ( strpos ( $ condition , '||' ) ) { $ conditions = explode ( '||' , $ condition ) ; $ conditions = array_map ( 'trim' , $ conditions ) ; $ conditionParts = [ ] ; foreach ( $ conditions as $ condition ) { list ( $ property , $ condition , $ valu...
Add the condition
14,182
protected function _buildCondition ( $ property , $ condition , $ value ) { switch ( $ condition ) { case self :: COND_EQUAL : return [ $ property => $ value ] ; case self :: COND_IN : return [ $ property => [ self :: MONGO_IN => ( array ) $ value ] ] ; case self :: COND_NOT_IN : return [ $ property => [ self :: MONGO_...
Build the condition
14,183
protected function _addCondition ( array $ condition ) { $ conditions = [ ] ; foreach ( $ condition as $ key => $ part ) { if ( $ key === self :: MONGO_OR ) { if ( isset ( $ this -> _conditions [ self :: MONGO_OR ] ) || isset ( $ this -> _conditions [ self :: MONGO_AND ] ) ) { if ( isset ( $ this -> _conditions [ self ...
Add the condition to the conditions list
14,184
public function count ( ) { $ cursor = $ this -> _adapter -> find ( $ this , null , null , true ) ; return $ cursor -> count ( ) ; }
Count the number of found records
14,185
public function assemblePipeline ( ) { $ aggregate = [ ] ; if ( ! empty ( $ this -> _conditions ) ) { $ aggregate [ ] = [ self :: MONGO_PIPE_MATCH => $ this -> _conditions ] ; } if ( ! empty ( $ this -> _groupDefinition ) ) { $ group = $ this -> _groupDefinition ; $ group [ MongoCollection :: DEFAULT_PRIMARY ] = ( $ th...
Assemble the aggregate pipeline
14,186
protected function _parseCondition ( $ condition ) { if ( ! preg_match ( '/ ([a-z0-9_\.]+) #property (?| (?:\s+([a-z0-9]+[\s_]?[a-z0-9]*) #keyword (?:\(|\s+))|(?:\s*([!=\<\>]+)\s*) #condition ) (.+) #value /ix' , $ condition , $ matches ) ) { throw new Exception ( 'Error in condition: "' . $ cond...
Parse the condition into a parts
14,187
protected function get ( $ endpoint , $ get = array ( ) ) { if ( $ get !== [ ] ) { $ endpoint .= '?' . http_build_query ( $ get ) ; } $ uri = new \ TYPO3 \ Flow \ Http \ Uri ( $ endpoint ) ; $ request = \ TYPO3 \ Flow \ Http \ Request :: create ( $ uri , 'GET' ) ; $ request -> setContent ( '' ) ; $ request = $ this -> ...
Method to do get requests to the API
14,188
public static function generateIcon ( $ icon , $ class = null ) { $ key = $ GLOBALS [ 'BOOTSTRAP' ] [ 'icons' ] [ 'active' ] ; return sprintf ( $ GLOBALS [ 'BOOTSTRAP' ] [ 'icons' ] [ 'sets' ] [ $ key ] [ 'template' ] , $ icon . ( $ class == null ? '' : ' ' . $ class ) ) ; }
generates code for an icon
14,189
public static function getIcons ( $ group = null ) { $ key = $ GLOBALS [ 'BOOTSTRAP' ] [ 'icons' ] [ 'active' ] ; if ( ! isset ( $ GLOBALS [ 'BOOTSTRAP' ] [ 'icons' ] [ 'sets' ] [ $ key ] [ 'icons' ] ) ) { if ( TL_MODE == 'BE' ) { if ( isset ( $ GLOBALS [ 'BOOTSTRAP' ] [ 'icons' ] [ 'sets' ] [ $ key ] [ 'stylesheet' ] ...
get all icons of a group as grouped array or as flat array
14,190
function store ( $ fieldFilters = null ) { if ( $ this -> attribute ( 'user_id' ) == eZUser :: currentUserID ( ) && eZINI :: instance ( ) -> variable ( 'eZStarRating' , 'UseUserSession' ) === 'enabled' ) { $ http = eZHTTPTool :: instance ( ) ; $ attributeIdList = $ this -> attribute ( 'contentobject_attribute_id' ) ; i...
Override store function to add some custom logic for setting create time and store contentobject_attribute_id in session to avoid several ratings from same user .
14,191
static function removeByObjectId ( $ contentobjectID , $ contentobjectAttributeId = null ) { $ cond = array ( 'contentobject_id' => $ contentobjectID ) ; if ( $ contentobjectAttributeId !== null ) { $ cond [ 'contentobject_attribute_id' ] = $ contentobjectAttributeId ; } eZPersistentObject :: removeObject ( self :: def...
Remove rating data by content object id and optionally attribute id .
14,192
static function fetch ( $ id ) { $ cond = array ( 'id' => $ id ) ; $ return = eZPersistentObject :: fetchObject ( self :: definition ( ) , null , $ cond ) ; return $ return ; }
Fetch rating by rating id!
14,193
static function fetchByObjectId ( $ contentobjectID , $ contentobjectAttributeId = null ) { $ cond = array ( 'contentobject_id' => $ contentobjectID ) ; if ( $ contentobjectAttributeId !== null ) { $ cond [ 'contentobject_attribute_id' ] = $ contentobjectAttributeId ; } $ return = eZPersistentObject :: fetchObjectList ...
Fetch rating data by content object id and optionally attribute id!
14,194
public function getOrderStateLabel ( $ stateOrOrder ) { $ state = $ stateOrOrder instanceof OrderInterface ? $ stateOrOrder -> getState ( ) : $ stateOrOrder ; return $ this -> translator -> trans ( OrderStates :: getLabel ( $ state ) ) ; }
Returns the order state label .
14,195
public function getOrderStateBadge ( $ stateOrOrder ) { $ state = $ stateOrOrder instanceof OrderInterface ? $ stateOrOrder -> getState ( ) : $ stateOrOrder ; return sprintf ( '<span class="label label-%s">%s</span>' , OrderStates :: getTheme ( $ state ) , $ this -> getOrderStateLabel ( $ state ) ) ; }
Returns the order state badge .
14,196
public function getOrderTotal ( OrderInterface $ order , $ ati = false ) { return $ this -> calculator -> calculateOrderTotal ( $ order , $ ati ) ; }
Returns the order total .
14,197
public function getOrderItemTotal ( OrderItemInterface $ item , $ ati = false ) { return $ this -> calculator -> calculateOrderItemTotal ( $ item , $ ati ) ; }
Returns the order item total .
14,198
public function filled ( $ key ) : bool { return $ this -> has ( $ key ) && ! empty ( $ this -> get ( $ key ) ) ; }
Determine if an input is present and not empty within the query or post bags .
14,199
public function is_wp_login ( ) { $ abs_path = \ str_replace ( [ '\\' , '/' ] , DIRECTORY_SEPARATOR , ABSPATH ) ; $ files = \ get_included_files ( ) ; if ( \ in_array ( $ abs_path . 'wp-login.php' , $ files ) || \ in_array ( $ abs_path . 'wp-register.php' , $ files ) ) { return true ; } if ( isset ( $ _GLOBALS [ 'pagen...
Detect whether the current request is to the login page .