idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
200
public function getModulesConfig ( ) { $ result = [ ] ; foreach ( $ this -> modules as $ moduleName => $ moduleConfig ) { $ className = $ moduleConfig [ 'className' ] ; $ module = new $ className ; if ( ! $ module instanceof AbstractModule ) { $ errMsg = sprintf ( 'Class "%s" must be extended from %s' , $ className , A...
Get config in modules
201
public function getModulesAutoloadConfig ( ) { $ isCacheInstance = $ this -> cache instanceof CacheInterface ; if ( $ isCacheInstance ) { if ( ( $ autoloadConfig = $ this -> cache -> getAutoloadModulesConfig ( ) ) !== false ) { return $ autoloadConfig ; } } $ autoloadConfig = $ this -> getModulesAutoloadConfigWithoutCa...
Get all module auto loader configuration
202
public function onResponse ( FilterResponseEvent $ event ) { $ kernel = $ event -> getKernel ( ) ; $ response = $ event -> getResponse ( ) ; $ content = $ response -> getContent ( ) ; foreach ( $ this -> toolbar -> getExtensions ( ) as $ extension ) { $ extension -> buildData ( ) ; } if ( false !== strpos ( $ content ,...
Response event action .
203
public function getValue ( ) : ? Range { if ( ! empty ( $ this -> value ) ) { $ result = new Range ; @ list ( $ from , $ to ) = explode ( $ this -> delimiter , $ this -> value ) ; if ( $ from && $ to ) { $ result -> from = DateTime :: createFromFormat ( $ this -> format , $ from ) ; $ result -> to = DateTime :: createF...
Vrati pole intervalu datumu
204
protected function _parseArg ( $ argv ) { for ( $ i = 0 ; $ i < count ( $ argv ) ; $ i ++ ) { if ( $ argv [ $ i ] != 'console' ) { if ( ! preg_match ( '#\[#' , $ argv [ $ i ] ) ) { array_push ( $ this -> _argv , $ argv [ $ i ] ) ; } else { $ data = '' ; for ( $ i = 0 ; $ i < count ( $ argv ) ; $ i ++ ) { $ data .= $ ar...
Parse terminal parameters to allow user to use spaces
205
public static function rrmdir ( $ dir , $ removeDir = false , $ except = [ ] ) { if ( is_dir ( $ dir ) ) { $ objects = scandir ( $ dir ) ; foreach ( $ objects as $ object ) { if ( $ object != "." && $ object != ".." ) { if ( filetype ( $ dir . "/" . $ object ) == "dir" ) { Terminal :: rrmdir ( $ dir . "/" . $ object , ...
Remove directory content
206
public function indexAction ( Request $ request ) { $ viewIndex = $ this -> get ( 'phlexible_gui.view.index' ) ; return [ 'scripts' => $ viewIndex -> get ( $ request ) , 'noScript' => $ viewIndex -> getNoScript ( ) , ] ; }
Render Frame .
207
public function menuAction ( ) { $ loader = $ this -> get ( 'phlexible_gui.menu.loader' ) ; $ items = $ loader -> load ( ) ; $ data = $ items -> toArray ( ) ; return new JsonResponse ( $ data ) ; }
Return menu .
208
public function routesAction ( Request $ request ) { $ routeExtractor = $ this -> get ( 'phlexible_gui.route_extractor' ) ; $ extractedRoutes = $ routeExtractor -> extract ( $ request ) ; $ content = sprintf ( 'Phlexible.Router.setData(%s);' , json_encode ( array ( 'baseUrl' => $ extractedRoutes -> getBaseUrl ( ) , 'ba...
Return routes .
209
public static function buildAttribString ( $ attribs , $ dblEnc = false ) { if ( ! $ dblEnc && \ is_array ( $ attribs ) ) { foreach ( $ attribs as $ k => $ v ) { if ( \ is_string ( $ v ) ) { $ attribs [ $ k ] = \ htmlspecialchars_decode ( $ v ) ; } } } return \ bdk \ Debug \ Utilities :: buildAttribString ( $ attribs )...
Build an attribute string
210
public static function buildTag ( $ name , $ attribs = array ( ) , $ innerhtml = '' , $ dblEnc = false ) { $ attribStr = self :: buildAttribString ( $ attribs , $ dblEnc ) ; return \ in_array ( $ name , self :: $ cfgStatic [ 'emptyTags' ] ) ? '<' . $ name . $ attribStr . ' />' : '<' . $ name . $ attribStr . '>' . $ inn...
Build an html tag
211
public static function getAbsUrl ( $ urlFrom , $ urlTo ) { if ( strpos ( $ urlTo , '://' ) !== false ) { return $ urlTo ; } $ urlAbs = $ urlTo ; if ( is_array ( $ urlFrom ) ) { $ urlParts = $ urlFrom ; } else { $ urlParts = Html :: parseUrl ( $ urlFrom ) ; } $ urlParts [ 'query' ] = null ; $ urlParts [ 'params' ] = arr...
Get absolute URL
212
public static function htmlentities ( $ str = '' , $ encodeTags = true , $ isXml = false , $ charset = null ) { $ debug = \ bdk \ Debug :: getInstance ( ) ; $ dbWas = $ debug -> setCfg ( 'collect' , false ) ; $ debug -> groupCollapsed ( __FUNCTION__ ) ; $ return = '' ; $ charsetsTry = array ( 'UTF-8' , 'ISO-8859-1' ) ;...
Convert all applicable characters to HTML entities .. does not double encode
213
public static function parseAttribString ( $ str , $ decode = true , $ decodeData = true ) { return \ bdk \ Debug \ Utilities :: parseAttribString ( $ str , $ decode , $ decodeData ) ; }
Parse string - o - attributes into a key = > value array
214
private static function getSelfUrlParams ( $ requestParams , $ paramsNew , $ opts ) { $ params = $ requestParams ; $ paramsQuery = Str :: parse ( $ _SERVER [ 'QUERY_STRING' ] ) ; $ cor = array_diff_assoc ( $ paramsQuery , $ _GET ) ; $ coa = array_diff_assoc ( $ _GET , $ paramsQuery ) ; foreach ( $ cor as $ k => $ v ) {...
get parameters for self url
215
protected function parse ( $ data ) { $ parsed = array ( ) ; $ parts = explode ( $ this -> normaliseWhitespace ( $ this -> fieldSeparator ) , $ this -> normaliseWhitespace ( trim ( $ data , " \t" ) ) ) ; if ( sizeof ( $ parts ) < 2 ) { throw new DomainException ( sprintf ( 'Expected a well-formed line of two fields "na...
Parsed a simple name separator value line into a name value pair .
216
public static function addBaseVariables ( array $ data = [ ] , ? string $ channel = null ) { $ channel = $ channel ?? static :: getDefaultChannel ( ) ; static :: $ baseData [ $ channel ] = static :: $ baseData [ $ channel ] ?? [ ] ; static :: $ baseData [ $ channel ] = array_merge ( static :: $ baseData [ $ channel ] ,...
Adds some data with specified channel to base data of all objects which will be created witch same channel afterwards
217
public function modifyValues ( $ modifiers , $ subKey = null ) { $ process = function ( & $ source ) use ( $ modifiers ) { foreach ( $ modifiers as $ key => $ value ) { if ( is_callable ( $ value ) ) { $ source [ $ key ] = $ value ( ( isset ( $ source [ $ key ] ) ? $ source [ $ key ] : null ) ) ; } else { $ source [ $ ...
Modify stored value with callable or scalar modifiers
218
public function getProperties ( $ value , ReflectionClass $ class , $ propertyFilter ) { $ properties = [ ] ; foreach ( self :: $ appProperties as $ property ) { try { $ val = $ value -> $ property ( ) ; if ( ! is_null ( $ val ) ) $ properties [ $ property ] = $ val ; } catch ( Exception $ e ) { } } return $ properties...
Get an array of Application object properties .
219
public function filterFrontend ( CollectionInterface $ results ) { return $ results -> filter ( function ( Language $ language ) { return $ language -> available_at_frontend === true ; } ) ; }
Filter the provided result set by languages that are available at the frontend .
220
public function filterBackend ( CollectionInterface $ results ) { return $ results -> filter ( function ( Language $ language ) { return $ language -> available_at_backend === true ; } ) ; }
Filter the provided result set by languages that are available at the backend .
221
public function addFile ( $ file , $ options = [ ] ) { if ( empty ( $ file ) || ! is_string ( $ file ) ) { throw new InvalidParamException ( 'Filename must be a string and cannot be empty' ) ; } elseif ( ! is_array ( $ options ) ) { throw new InvalidParamException ( 'Options value must be an array' ) ; } $ this -> file...
Adds JS file into a module
222
public function addDependency ( ModuleInterface $ depends ) { if ( $ depends -> getFiles ( ) === [ ] ) { foreach ( $ depends -> getDependencies ( ) as $ dependency ) { $ this -> addDependency ( $ dependency ) ; } return $ this ; } $ this -> dependencies [ $ depends -> getName ( ) ] = $ depends ; return $ this ; }
Adds dependency to a module
223
protected function _modify ( array $ data = null ) { if ( $ this -> is_valid ( ) ) { if ( isset ( $ data [ 'password' ] ) ) { $ this -> password = Auth :: hash ( $ data [ 'password' ] ) ; } return $ this -> save ( ) ; } return $ this -> errors -> full_messages ( ) ; }
Check validation and hashing password
224
public function configure ( ) { $ this -> setEnv ( $ this -> getEnvFromEnvironmentVariables ( ) ) ; $ this -> config ( 'directory.root' , dirname ( dirname ( __DIR__ ) ) ) ; $ this -> addAppPathUsePsr4 ( __DIR__ , __NAMESPACE__ , 'Samurai\\' , self :: PRIORITY_LOW ) ; $ this -> config ( 'directory.config.samurai' , 'Co...
base configure .
225
protected function initializers ( ) { $ initializers = [ ] ; $ initializer_files = $ this -> loader -> find ( 'Config/Initializer/*Initializer.php' ) ; foreach ( $ initializer_files as $ file ) { require_once $ file -> getRealPath ( ) ; $ class = $ file -> getClassName ( ) ; $ initializers [ ] = new $ class ( ) ; } uso...
call initializers .
226
public function environment ( ) { $ env = $ this -> getEnv ( ) ; $ name = 'Config/Environment/' . ucfirst ( $ env ) . '.php' ; foreach ( $ this -> loader -> find ( $ name ) as $ file ) { require_once $ file -> getRealPath ( ) ; $ class = $ file -> getClassName ( ) ; $ initializer = new $ class ( ) ; $ initializer -> co...
environment settings .
227
public function setEnv ( $ env ) { if ( ! $ env ) $ env = self :: ENV_DEVELOPMENT ; $ this -> env = $ env ; $ this -> config ( 'env' , $ this -> env ) ; return $ this -> getEnv ( ) ; }
set env .
228
public function config ( $ key = null , $ value = null ) { if ( ! $ key ) return $ this -> config ; $ is_array = false ; if ( substr ( $ key , - 1 ) === '.' ) { $ is_array = true ; $ key = substr ( $ key , 0 , - 1 ) ; } if ( $ value !== null ) { if ( $ is_array ) { if ( ! array_key_exists ( $ key , $ this -> config ) )...
accessor config .
229
public function configHierarchical ( $ key = null ) { $ config = [ ] ; $ all = $ this -> config ( $ key ) ; if ( ! is_array ( $ all ) ) $ all = array ( $ key => $ all ) ; foreach ( $ all as $ _key => $ _val ) { $ keys = explode ( '.' , $ _key ) ; $ value = & $ config ; while ( $ key = array_shift ( $ keys ) ) { if ( $ ...
get config hierarchical splited by dot .
230
public function addAppPathUsePsr4 ( $ path , $ namespace , $ psr4_prefix , $ priority = self :: PRIORITY_LOW ) { $ dirs = $ this -> config ( 'directory.apps' ) ; if ( ! $ dirs ) $ dirs = [ ] ; $ root = substr ( $ path , 0 , - 1 - strlen ( $ namespace ) + strlen ( $ psr4_prefix ) ) ; $ dirs [ ] = [ 'dir' => $ path , 'ro...
add application path using psr4 .
231
public function getControllerDirectories ( ) { $ dirs = [ ] ; $ controller_ns = $ this -> config ( 'controller.namespaces' ) ; foreach ( $ this -> config ( 'directory.apps' ) as $ dir ) { if ( in_array ( $ dir [ 'namespace' ] , $ controller_ns ) ) $ dirs [ ] = $ dir [ 'dir' ] . DS . 'Controller' ; } return $ dirs ; }
get controller dirs
232
public function getValue ( ) { if ( ! isset ( $ this -> input [ $ this -> inputName ] ) ) { return null ; } return $ this -> input [ $ this -> inputName ] ; }
Return the value to be validated
233
public function getArg ( $ pos = null ) { if ( $ pos === null ) { return $ this -> args ; } return isset ( $ this -> args [ $ pos ] ) ? $ this -> args [ $ pos ] : $ this -> args ; }
Get arg or args
234
public function getRoutesWithCache ( ) { if ( $ this -> cacheService == null ) { return $ this -> getRoutesWithoutCache ( ) ; } else { $ routes = $ this -> cacheService -> get ( 'splashWordpressRoutes' ) ; if ( $ routes == null ) { $ routes = $ this -> getRoutesWithoutCache ( ) ; $ this -> cacheService -> set ( 'splash...
Returns the list of routes as an array of arrays . Uses the cache mechanism if available .
235
public function getRoutesWithoutCache ( ) { $ urlsList = array ( ) ; foreach ( $ this -> routeProviders as $ routeProvider ) { $ tmpUrlList = $ routeProvider -> getUrlsList ( null ) ; $ urlsList = array_merge ( $ urlsList , $ tmpUrlList ) ; } $ items = array ( ) ; foreach ( $ urlsList as $ urlCallback ) { $ url = $ url...
Returns the list of routes as an array of arrays . Bypasses the cache mechanism .
236
public function connect ( ) : DriverInterface { $ options = $ this -> getConfig ( ) -> get ( ) ; $ optionsDriver = $ options [ 'driver_options' ] -> get ( ) ; try { $ connection = new MongoManager ( $ this -> getDsn ( ) , $ this -> getOptions ( $ options , self :: AVAILABLE_OPTIONS ) , $ this -> getOptions ( $ optionsD...
Initiate connection with database
237
private function getOptions ( array $ options , array $ allowed ) : array { $ result = [ ] ; foreach ( $ options as $ key => $ value ) { if ( \ in_array ( $ key , $ allowed , false ) ) { $ result [ $ key ] = $ value ; } } return $ result ; }
Generate options array
238
private function getQuery ( array $ where , array $ options ) : MongoQuery { try { $ query = new MongoQuery ( $ where , $ options ) ; } catch ( InvalidArgumentException $ e ) { new Exception ( 'WriteConcern could not to be initiated' ) ; } return $ query ; }
Create query object from filter and option arrays
239
public function update ( array $ data , array $ filter = [ ] , array $ updateOptions = [ ] ) { $ bulk = $ this -> getBulk ( ) ; $ bulk -> update ( $ filter , $ data , $ updateOptions ) ; try { $ response = $ this -> getInstance ( ) -> executeBulkWrite ( $ this -> getParam ( 'database' ) . '.' . $ this -> getCollection ...
Update data in database
240
private function getCommand ( $ query ) : MongoCommand { try { $ command = new MongoCommand ( $ query ) ; } catch ( InvalidArgumentException $ e ) { new Exception ( 'WriteConcern could not to be initiated' ) ; } return $ command ; }
Create command from query
241
private function getStatus ( Theme $ theme ) { if ( $ theme -> type !== 'Backend' ) { return setting ( 'core::template' ) === $ theme -> getName ( ) ; } return config ( 'society.core.core.admin-theme' ) === $ theme -> getName ( ) ; }
Check if the theme is active based on its type .
242
public function findByClass ( $ className ) { $ result = [ ] ; foreach ( $ this -> _traits as $ trait ) { if ( $ trait -> matchClassName ( $ className ) ) { $ result [ ] = $ trait ; } } $ result = SortUtils :: sortReflections ( $ result ) ; return $ result ; }
Retrieve all traits by matching className
243
public function setFlash ( $ key , $ value ) { $ key = $ this -> explode ( $ key ) ; array_unshift ( $ key , __CLASS__ , 'flash' , 'next' ) ; $ this -> set ( $ key , $ value ) ; }
Set a flash value that will only be available on the next page request .
244
public function getFlash ( $ key , $ default = null ) { $ key = $ this -> explode ( $ key ) ; array_unshift ( $ key , __CLASS__ , 'flash' , 'now' ) ; return $ this -> get ( $ key , $ default ) ; }
Get a flash value that was set on the previous page request .
245
private function started ( ) { if ( is_null ( self :: $ started ) ) { self :: $ started = ( session_status ( ) === PHP_SESSION_ACTIVE ) ? true : session_start ( ) ; if ( self :: $ started ) { if ( ! isset ( $ _SERVER [ 'HTTP_X_REQUESTED_WITH' ] ) || strtolower ( $ _SERVER [ 'HTTP_X_REQUESTED_WITH' ] ) != 'xmlhttpreques...
Start a new or update an existing session .
246
public function letOnContext ( $ constraint ) { $ this -> defaultValue ( static :: FIELD_SELF , null ) ; return $ this -> let ( static :: FIELD_SELF , $ constraint ) ; }
Add a constraint that only works on the context . These are complex constraints that usually work on more than one field at a time .
247
public function defaultValue ( $ field , $ value ) { Arguments :: define ( Boa :: string ( ) , Boa :: any ( ) ) -> check ( $ field , $ value ) ; $ this -> defaults = $ this -> defaults -> insert ( $ field , $ value ) ; return $ this ; }
Set the default value of a field .
248
public function let ( $ field , $ constraint ) { Arguments :: define ( Boa :: string ( ) , Boa :: either ( Boa :: instance ( AbstractConstraint :: class ) , Boa :: arrOf ( Boa :: instance ( AbstractConstraint :: class ) ) ) ) -> check ( $ field , $ constraint ) ; if ( ! $ this -> constraints -> member ( $ field ) ) { $...
Add one or more constraints to a field .
249
public function required ( $ fields ) { Arguments :: define ( Boa :: either ( Boa :: string ( ) , Boa :: arrOf ( Boa :: string ( ) ) ) ) -> check ( $ fields ) ; if ( ! is_array ( $ fields ) ) { $ fields = [ $ fields ] ; } $ this -> required = $ this -> required -> append ( ArrayList :: of ( $ fields ) ) ; return $ this...
Add one or more fields to the list of fields that are required .
250
public function make ( ) { return new Spec ( $ this -> constraints -> toArray ( ) , $ this -> defaults -> toArray ( ) , $ this -> required -> toArray ( ) ) ; }
Build an instance of the defined Spec .
251
protected function renderTpl ( $ tpl , $ data = array ( ) ) { if ( ! empty ( $ tpl ) ) { extract ( $ data ) ; ob_start ( ) ; eval ( '?>' . $ tpl . '<?php ' ) ; $ tpl = ob_get_clean ( ) ; } return $ tpl ; }
Renders a . tpl . php file .
252
public function filter ( array $ data ) { $ filteredData = [ ] ; foreach ( $ data as $ value ) { if ( $ this -> match ( $ value ) ) { $ filteredData [ ] = $ value ; } } return $ filteredData ; }
Performs filtering of given array
253
public function getSlug ( $ langCode ) { $ slug = false ; foreach ( $ this -> i18n as $ i18nModel ) { if ( $ i18nModel -> lang_code == $ langCode ) { $ slug = $ i18nModel -> slug ; break ; } } return $ slug ; }
Get slug of this model for selected language
254
public function detach ( EventManagerInterface $ events ) { $ sharedManager = $ events -> getSharedManager ( ) ; foreach ( $ this -> listeners as $ index => $ listeners ) { if ( $ listeners === $ this ) { continue ; } if ( $ listeners instanceof ListenerAggregateInterface ) { $ listeners -> detach ( $ events ) ; } $ ev...
Detach all previously attached listeners .
255
protected function checkLazyLoad ( ) { if ( $ this -> lazyLoadInitiated === true ) { return ; } $ this -> lazyLoad ( ) ; $ this -> generateKeys ( ) ; $ this -> lazyLoadInitiated = true ; }
Performs lazy load checks and loads items if required .
256
public function callSetter ( & $ object , $ key , $ value ) { $ method = 'set' . ucfirst ( $ key ) ; if ( method_exists ( $ object , $ method ) ) { $ object -> $ method ( $ value ) ; return true ; } return false ; }
Call object set method for a key and pass value
257
public function indexAction ( ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ visits = $ em -> getRepository ( 'CoreExtraBundle:Visit' ) -> findAll ( ) ; return array ( 'visits' => $ visits , ) ; }
Lists all visit entities .
258
public function newAction ( Request $ request ) { $ visit = new Visit ( ) ; $ form = $ this -> createForm ( 'CoreExtraBundle\Form\VisitType' , $ visit ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> pers...
Creates a new visit entity .
259
public function showAction ( Visit $ visit ) { $ deleteForm = $ this -> createDeleteForm ( $ visit ) ; return array ( 'visit' => $ visit , 'delete_form' => $ deleteForm -> createView ( ) , ) ; }
Finds and displays a visit entity .
260
private function createDeleteForm ( Visit $ visit ) { return $ this -> createFormBuilder ( ) -> setAction ( $ this -> generateUrl ( 'visit_delete' , array ( 'id' => $ visit -> getId ( ) ) ) ) -> setMethod ( 'DELETE' ) -> getForm ( ) ; }
Creates a form to delete a visit entity .
261
public function find ( $ key ) { $ template = $ this -> getCollection ( ) -> get ( $ key ) ; if ( $ template !== null ) { return $ template ; } throw new NotFoundException ( "Media template $key not found." ) ; }
Find template .
262
public function updateTemplate ( TemplateInterface $ template ) { $ template -> setRevision ( $ template -> getRevision ( ) + 1 ) ; $ this -> dumper -> dumpTemplate ( $ template ) ; }
Update template .
263
public static function register ( LoggerInterface $ logger = null , ExceptionConfig $ cfg = null ) { self :: $ registered = true ; $ class = get_called_class ( ) ; $ handler = new $ class ( $ logger , $ cfg ) ; set_exception_handler ( [ $ handler , 'handle' ] ) ; self :: $ lastRegisteredHandler = & $ handler ; return $...
Registers the exception handler
264
protected function handleCLI ( $ e ) { $ this -> console -> write ( '<eb>Uncaught ' . get_class ( $ e ) . ': </>' ) -> write ( '<e>[' . $ e -> getCode ( ) . '] ' . $ e -> getMessage ( ) . '</>' , true ) -> write ( '<e>Raised in </>' ) -> write ( '<eu>' . $ e -> getFile ( ) . '</>' ) -> write ( '<e> @ line </>' ) -> wri...
Handles the exception with CLI output
265
protected function echoPreviousExceptions ( $ e , $ level = 0 ) { if ( $ level < $ this -> config -> prevExceptionDepth && $ e ) { if ( $ this -> isCLI ) { $ this -> console -> write ( '<eb>Preceded by </>' ) -> write ( '<e>[' . $ e -> getCode ( ) . '] ' . $ e -> getMessage ( ) . '</>' ) -> write ( '<e> @ ' . $ e -> ge...
Echoes previous exceptions if applicable
266
protected function handleHTML ( $ e ) { ?> <div class="text-center"> <div class="alo-err alert alert-danger"> <div> <span class="alo-bold">Uncaught <?= get_class ( $ e ) ?> : </span> <span>[ <?= $ e -> getCode ( ) ?> ] <?= $ e -> getMessa...
Handles an exception with HTML output
267
protected function log ( $ e , $ includeLocation = true ) { $ msg = '[' . $ e -> getCode ( ) . '] ' . $ e -> getMessage ( ) ; if ( $ this -> config -> logExceptionLocation && $ includeLocation ) { $ msg .= ' (occurred in ' . $ e -> getFile ( ) . ' @ line ' . $ e -> getLine ( ) . ')' ; } $ this -> logger -> error ( $ ms...
Logs a message if the logger is enabled
268
public function handle ( GetResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ session = $ request -> getSession ( ) ; if ( null === $ session || null === $ token = $ this -> securityContext -> getToken ( ) ) { return ; } if ( ! $ this -> hasSessionExpired ( $ session ) ) { return ; } if ( null !== $ t...
Handles expired sessions .
269
public function fetchAll ( $ sort = null ) { $ select = $ this -> getFullTree ( ) ; $ select = $ this -> setSortOrder ( $ select , $ sort ) ; return $ this -> fetchResult ( $ select ) ; }
Gets all items in tree .
270
public function getFullTree ( ) { $ select = $ this -> getSql ( ) -> select ( ) ; $ select -> from ( [ 'child' => $ this -> getTable ( ) ] ) -> columns ( [ Select :: SQL_STAR , 'depth' => new Expression ( '(COUNT(parent.' . $ this -> getPrimaryKey ( ) . ') - 1)' ) ] ) -> join ( [ 'parent' => $ this -> getTable ( ) ] , ...
Gets the full tree from database
271
public function getPathwayByChildId ( $ id ) { $ select = $ this -> getSql ( ) -> select ( ) ; $ select -> from ( [ 'child' => $ this -> getTable ( ) ] ) -> columns ( [ ] ) -> join ( [ 'parent' => $ this -> getTable ( ) ] , 'child.' . self :: COLUMN_LEFT . ' BETWEEN parent.' . self :: COLUMN_LEFT . ' AND parent.' . sel...
Get the pathway of of the child by its id .
272
protected function updateTree ( $ lft_rgt , $ operator , $ offset ) { $ lft = new Where ; $ rgt = new Where ; $ lftUpdate = $ this -> update ( [ self :: COLUMN_LEFT => new Expression ( self :: COLUMN_LEFT . $ operator . $ offset ) ] , $ lft -> greaterThan ( self :: COLUMN_LEFT , $ lft_rgt ) ) ; $ rgtUpdate = $ this -> ...
Updates left and right values of tree
273
protected function getPosition ( $ id ) { $ cols = [ self :: COLUMN_LEFT , self :: COLUMN_RIGHT , 'width' => new Expression ( self :: COLUMN_RIGHT . ' - ' . self :: COLUMN_LEFT . ' + 1' ) , ] ; $ select = $ this -> getSelect ( ) ; $ where = new Where ; $ where -> equalTo ( $ this -> getPrimaryKey ( ) , $ id ) ; $ selec...
Get the position of a child in the tree
274
public function insertRow ( array $ data , $ position = 0 , $ insertType = self :: INSERT_NODE ) { $ num = $ this -> fetchAll ( ) -> count ( ) ; if ( $ num && $ position ) { $ row = $ this -> getPosition ( $ position ) ; $ lft_rgt = ( $ insertType === self :: INSERT_NODE ) ? $ row -> getRgt ( ) : $ row -> getLft ( ) ; ...
Insert a row into tree
275
public function delete ( $ where , $ table = null ) { if ( is_array ( $ where ) ) { $ pk = $ where [ $ this -> getPrimaryKey ( ) ] ; } else { $ pk = ( int ) $ where ; } $ row = $ this -> getPosition ( $ pk ) ; $ where = new Where ; $ where -> between ( self :: COLUMN_LEFT , $ row -> getLft ( ) , $ row -> getRgt ( ) ) ;...
Deletes a row from tree .
276
public function addTwigPath ( string $ namespace , string $ path ) : ExtensionInterface { if ( $ this -> driver ) { throw new \ RuntimeException ( 'Driver has already been created. Namespaces cannot be added.' ) ; } $ this -> twigNamespaces [ $ namespace ] [ ] = $ path ; return $ this ; }
Add a directory to the Twig loader .
277
private function getPhantomProcess ( $ viewPath ) { $ system = $ this -> getSystem ( ) ; $ phantom = __DIR__ . '/bin/' . $ system . '/phantomjs' . $ this -> getExtension ( $ system ) ; return new Process ( $ phantom . ' invoice.js ' . $ viewPath , __DIR__ ) ; }
Get the PhantomJS process instance .
278
private function getSystem ( ) { $ uname = strtolower ( php_uname ( ) ) ; if ( str_contains ( $ uname , 'darwin' ) ) { return 'macosx' ; } elseif ( str_contains ( $ uname , 'win' ) ) { return 'windows' ; } elseif ( str_contains ( $ uname , 'linux' ) ) { return PHP_INT_SIZE === 4 ? 'linux-i686' : 'linux-x86_64' ; } else...
Get the operating system for the current platform .
279
private function writeViewForImaging ( InvoiceInterface $ invoice , $ storagePath ) { $ html = $ this -> htmlGenerator -> generate ( $ invoice ) ; $ storagePath = $ storagePath ? : storage_path ( ) . '/framework' ; $ this -> files -> put ( $ path = $ storagePath . '/' . $ invoice -> getId ( ) . '.pdf' , $ html ) ; retu...
Write the view HTML so PhantomJS can access it .
280
public function generate ( InvoiceInterface $ invoice , $ storagePath = '/tmp' ) { $ viewPath = $ this -> writeViewForImaging ( $ invoice , $ storagePath ) ; $ this -> getPhantomProcess ( $ viewPath ) -> setTimeout ( 10 ) -> run ( ) ; return $ this -> files -> get ( $ viewPath ) ; }
Get the rendered PDF of the invoice .
281
public function addRoute ( Route $ route ) { if ( ! in_array ( $ route , $ this -> routes ) ) { $ this -> routes [ ] = $ route ; } }
Add a route to the array of routes if not already in the array .
282
private function FindRouteMatch ( ) { $ route = new Route ( ) ; $ route -> setDefaultUrl ( Config :: Init ( $ this -> app ) -> Get ( \ Puzzlout \ Framework \ Enums \ AppSettingKeys :: DefaultUrl ) ) ; $ this -> getRoute ( $ route , $ this -> url ) ; return $ route ; }
Instanciate the Route object from the current request .
283
public function setPath ( string $ path = '' ) : void { $ this -> path = '/' ; if ( $ path != '' ) { $ this -> path .= \ substr ( $ path , 0 , 1 ) === '/' ? \ substr ( $ path , 1 ) : $ path ; } }
Sets new cookie path
284
public function setDomain ( string $ domain = '' , bool $ forSubdomains = true ) : void { $ subdomainIndicator = $ forSubdomains === true ? '.' : '' ; $ this -> domain = \ sprintf ( '%s%s' , $ subdomainIndicator , \ preg_replace ( '/^(\.)?(preview\.)?/' , '' , $ domain ) ) ; }
Sets new cookie domain and whether cookie should be available for subdomains or not .
285
public function add ( $ command , $ path , array $ arguments = array ( ) , array $ options = array ( ) ) { $ dependsOn = ( array ) Hash :: get ( $ options , 'dependsOn' ) ; $ unique = ( bool ) Hash :: get ( $ options , 'unique' ) ; unset ( $ options [ 'dependsOn' ] , $ options [ 'unique' ] ) ; $ task = compact ( 'comma...
Adds new task
286
public function stop ( $ taskId , $ maxRetries = 10 ) { $ task = $ this -> read ( null , $ taskId ) ; if ( ! $ task ) { throw new NotFoundException ( "Task id=$taskId not found!" ) ; } switch ( $ task [ $ this -> alias ] [ 'status' ] ) { case TaskType :: FINISHED : case TaskType :: STOPPING : case TaskType :: STOPPED :...
Stop task by id
287
public function restart ( $ taskId ) { if ( ! $ this -> stop ( $ taskId ) ) { return false ; } $ task = array ( 'id' => null , 'stderr' => '' , 'stdout' => '' , 'status' => TaskType :: UNSTARTED , 'code' => '' , 'code_string' => '' , 'started' => '' , 'stopped' => '' , 'server_id' => 0 , ) + $ this -> read ( null , $ t...
Restart task by id
288
public function remove ( $ taskId , $ maxRetries = 10 ) { if ( ! $ this -> stop ( $ taskId , $ maxRetries ) ) { return false ; } return ( bool ) $ this -> delete ( $ taskId ) ; }
Delete task by id
289
protected function toggleButton ( ) { $ options = array ( 'model' => $ this -> model , 'attribute' => $ this -> attribute ) ; if ( isset ( $ this -> htmlOptions [ 'options' ] ) ) { $ options = CMap :: mergeArray ( $ options , $ this -> htmlOptions [ 'options' ] ) ; unset ( $ this -> htmlOptions [ 'options' ] ) ; } $ op...
Renders a toogle button
290
protected function markdownEditorJs ( ) { if ( isset ( $ this -> htmlOptions [ 'width' ] ) ) { $ width = $ this -> htmlOptions [ 'width' ] ; unset ( $ this -> htmlOptions [ 'width' ] ) ; } if ( isset ( $ this -> htmlOptions [ 'height' ] ) ) { $ height = $ this -> htmlOptions [ 'height' ] ; unset ( $ this -> htmlOptions...
Renders a Markdown Editor .
291
protected static function _tagPattern ( $ open = true , $ selfClose = false ) { if ( true === $ open ) { return static :: _openStartDelimiter ( $ selfClose ) . self :: ValuePlaceholder . static :: _openEndDelimiter ( $ selfClose ) ; } return static :: _closeStartDelimiter ( ) . self :: ValuePlaceholder . static :: _clo...
Cleans and trims a tag
292
protected function prepareLocal ( ) { if ( $ this -> isSmooth ( ) ) return ; $ size = filesize ( $ this -> path ) ; $ this -> setSize ( $ size ) ; if ( ! $ this -> hasDeflation ( ) ) $ this -> setDeflatedSize ( $ size ) ; $ this -> setRawCrc ( hash_file ( 'crc32b' , $ this -> path , TRUE ) ) ; }
Prepare the data required for the file header . size deflatedSize crc32 ...
293
public function make ( array $ attributes = [ ] ) { if ( $ this -> type === null ) { throw new InvalidArgumentException ( "You have to set the type of file!" ) ; } if ( $ this -> amount === null ) { return $ this -> makeInstance ( $ attributes ) ; } if ( $ this -> amount < 1 ) { return collect ( ) ; } return $ this -> ...
Make a file or files
294
protected function makeInstance ( array $ attributes ) { if ( in_array ( $ this -> type , [ 'jpg' , 'png' ] ) ) { $ properties = array_only ( $ attributes , [ 'height' , 'width' , 'text' , 'background' , 'color' ] ) ; $ properties [ 'type' ] = $ this -> type ; $ attributes = array_diff ( $ attributes , $ properties ) ;...
Make instance from file or generated file .
295
protected function file ( array $ attributes , $ path ) { $ filesystem = new Filesystem ; $ file = new UploadedFile ( $ path , last ( explode ( '/' , $ path ) ) , $ filesystem -> mimeType ( $ path ) , $ filesystem -> size ( $ path ) , null , true ) ; if ( count ( $ attributes ) ) { return collect ( array_merge ( compac...
Make uploaded file instance
296
private function loadFromExtensions ( $ content ) { foreach ( $ content as $ namespace => $ values ) { if ( in_array ( $ namespace , [ 'imports' , 'parameters' ] ) ) { continue ; } if ( ! is_array ( $ values ) ) { $ values = [ ] ; } $ this -> configCollection -> add ( $ namespace , $ values ) ; } }
Loads from Extensions
297
protected function getCoordParams ( array $ elementRef = null , $ x = 0 , $ y = 0 ) { return ( array ) $ elementRef + [ 'x' => ( int ) $ x , 'y' => ( int ) $ y , ] ; }
Build coordinate parameters for action .
298
protected function assertIsDown ( $ isDown = true ) { if ( $ this -> isDown != $ isDown ) { $ downText = $ isDown ? "up" : "down" ; throw new WebDriver_Exception ( "Touch pointer should be {$downText} for this action" ) ; } return $ this ; }
Throws exception if pointer down state is wrong .
299
protected function switchIsDown ( $ isDown = true ) { $ this -> assertIsDown ( ! $ isDown ) ; $ this -> isDown = ( bool ) $ isDown ; return $ this ; }
Switches to given pointer down state throwing exception if current state is wrong .