idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
5,300
public function instantiate ( $ strictMethods = true , $ constructorArgs = [ ] ) { $ originalClassFiltered = preg_replace ( '~[^a-z0-9]~i' , '_' , $ this -> originalClass ) ; $ className = 'mock_' . $ originalClassFiltered . '_' . self :: $ mockCount ; self :: $ mockCount ++ ; eval ( $ this -> build ( $ className ) ) ;...
Create the mock instance .
5,301
public function open ( string $ resource , string $ withClass = 'stubbles\streams\file\FileInputStream' ) { if ( ! class_exists ( $ withClass ) ) { throw new \ InvalidArgumentException ( 'Can not open ' . $ resource . ' with ' . $ withClass . ', class does not exit.' ) ; } return new $ withClass ( $ this -> checkedPath...
opens an input stream to read resource contents
5,302
public function load ( string $ resource , callable $ loader = null ) { $ checkedPath = $ this -> checkedPathFor ( $ resource ) ; if ( null == $ loader ) { return file_get_contents ( $ checkedPath ) ; } return $ loader ( $ checkedPath ) ; }
loads resource contents
5,303
private function checkedPathFor ( string $ resource ) : string { $ completePath = $ this -> completePath ( $ resource ) ; if ( ! file_exists ( $ completePath ) ) { throw new \ DomainException ( 'Resource ' . $ completePath . ' not found' ) ; } if ( ! $ this -> rootpath -> contains ( $ completePath ) ) { throw new \ Out...
completes path for given resource
5,304
private function completePath ( string $ resource ) : string { if ( substr ( $ resource , 0 , strlen ( ( string ) $ this -> rootpath ) ) == $ this -> rootpath ) { return $ resource ; } return $ this -> rootpath . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'main' . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_...
returns complete path for given resource
5,305
public function availableResourceUris ( string $ resourceName ) : array { $ resourceUris = array_values ( array_filter ( array_map ( function ( string $ sourcePath ) use ( $ resourceName ) : string { return str_replace ( '/src/main/php' , '/src/main/resources' , $ sourcePath ) . DIRECTORY_SEPARATOR . $ resourceName ; }...
returns a list of all available uris for a resource
5,306
public function shareInstance ( $ instance , $ reference = null ) { if ( ! is_object ( $ instance ) ) { return false ; } $ concrete = get_class ( $ instance ) ; if ( ! empty ( $ reference ) && ( $ reference !== $ concrete ) ) { $ alias = $ reference ; $ this -> createAlias ( $ concrete , $ alias ) ; } return $ this -> ...
Shares an already created instance via the container ;
5,307
public function createAlias ( $ reference , $ alias = null ) { if ( is_array ( $ reference ) ) { foreach ( $ reference as $ key => $ class ) { $ this -> createAlias ( $ class , $ key ) ; } return true ; } foreach ( ( ! is_array ( $ alias ) ? [ $ alias ] : $ alias ) as $ key ) { $ this -> aliases [ $ key ] = $ reference...
Creates a map of class alias stored in the container . A class can have multiple conatiners ;
5,308
public function createInstance ( $ reference , array $ parameters = [ ] , $ shared = true ) { $ reference = $ this -> mapReference ( $ reference ) ; if ( isset ( $ this [ $ reference ] ) ) { return $ this [ $ reference ] ; } $ class = new ReflectionClass ( $ reference ) ; if ( ! $ class -> isInstantiable ( ) ) { throw ...
Adds an object instance
5,309
public function mapReference ( $ alias ) { $ reference = array_key_exists ( $ alias , $ this -> aliases ) ; if ( array_key_exists ( $ alias , $ this -> aliases ) ) { return $ this -> aliases [ $ alias ] ; } return $ alias ; }
Maps an alias to a reference ;
5,310
protected function wrapInCallable ( $ class , array $ parameters = [ ] ) { return function ( $ container ) use ( $ class , $ parameters ) { if ( ( $ constructor = $ class -> getConstructor ( ) ) !== null ) { if ( ( $ required = $ constructor -> getNUmberOfParameters ( ) ) > 0 ) { $ dependencies = $ constructor -> getPa...
Wraps the Class in a callable which can look up dependencies automatically AKA . Serview locator
5,311
public function createReference ( $ reference , Closure $ callable , array $ parameters = [ ] , $ shared = false ) { $ reference = $ this -> mapReference ( $ reference ) ; $ this [ $ reference ] = ( $ shared ) ? static :: share ( $ callable ) : static :: protect ( $ callable ) ; return $ this [ $ reference ] ; }
Adds an unistantitated reference to a class
5,312
protected static function share ( $ callable ) { if ( ! is_object ( $ callable ) || ! method_exists ( $ callable , '__invoke' ) ) { throw new InvalidArgumentException ( 'Service definition is not a Closure or invokable object.' ) ; } return function ( $ container ) use ( $ callable ) { static $ object ; if ( null === $...
Returns a closure that stores the result of the given service definition for uniqueness in the scope of this instance of Pimple .
5,313
public function getRawReference ( $ reference ) { $ reference = $ this -> mapReference ( $ reference ) ; if ( ! array_key_exists ( $ reference , $ this -> container ) ) { throw new InvalidArgumentException ( sprintf ( 'Identifier "%s" is not defined.' , $ reference ) ) ; } return $ this -> container [ $ reference ] ; }
Gets the raw container reference
5,314
public static function limitText ( $ str , $ sentencesToDisplay = 2 ) { $ nakedBody = \ preg_replace ( '/\s+/' , ' ' , \ strip_tags ( $ str ) ) ; $ sentences = \ preg_split ( '/(\.|\?|\!)(\s)/' , $ nakedBody ) ; if ( \ count ( $ sentences ) <= $ sentencesToDisplay ) { return $ nakedBody ; } $ stopAt = 0 ; foreach ( $ s...
Limits text to given sentences
5,315
public static function slowEquals ( $ str1 , $ str2 ) { $ l1 = \ strlen ( $ str1 ) ; $ l2 = \ strlen ( $ str2 ) ; $ diff = $ l1 ^ $ l2 ; for ( $ i = 0 ; $ i < $ l1 && $ i < $ l2 ; ++ $ i ) { $ diff |= \ ord ( $ str1 [ $ i ] ) ^ \ ord ( $ str2 [ $ i ] ) ; } return $ diff === 0 ; }
Compares two strings for quality in length - constant time
5,316
public static function headerStringToArray ( $ str ) { if ( ! \ is_string ( $ str ) ) { throw new \ InvalidArgumentException ( '$str not a string' ) ; } $ arr = array ( ) ; $ header = '' ; foreach ( \ explode ( "\r\n" , \ trim ( $ str ) ) as $ hStr ) { $ header = \ explode ( ':' , $ hStr , 2 ) ; if ( \ strlen ( $ hStr ...
Parses a string containing a HTTP header into an associative array
5,317
public static function strInArray ( array $ arr , $ str , $ caseSensitive = true ) { if ( ! \ is_string ( $ str ) ) { throw new \ InvalidArgumentException ( '$str not a string' ) ; } if ( $ caseSensitive ) { return \ in_array ( $ str , $ arr , true ) ; } $ str = \ strtolower ( $ str ) ; foreach ( $ arr as $ v ) { if ( ...
Checks whether a given string exists in an array optionally case insensitive
5,318
final public function normalizeDatabaseDriver ( string $ driverName ) { if ( is_string ( $ driverName ) && trim ( $ driverName ) ) { $ driverName = trim ( strtolower ( $ driverName ) ) ; $ driverSchemeAliases = [ 'db2' => 'ibm_db2' , 'drizzle' => 'drizzle_pdo_mysql' , 'mssql' => 'pdo_sqlsrv' , 'mysql' => 'pdo_mysql' , ...
Check Database driver available for Doctrine and choose the best driver of sqlsrv an oci
5,319
public function trimTableSelector ( $ table ) { if ( is_array ( $ table ) ) { foreach ( $ table as $ key => $ value ) { $ table [ $ key ] = $ this -> trimTableSelector ( $ value ) ; } return $ table ; } elseif ( is_object ( $ table ) ) { foreach ( get_object_vars ( $ table ) as $ key => $ value ) { $ table -> { $ key }...
Trimming table for safe usage
5,320
public function quoteIdentifiers ( $ quoteStr ) { if ( $ quoteStr instanceof \ Closure || is_resource ( $ quoteStr ) ) { throw new \ InvalidArgumentException ( "Invalid value to be quote, quote value could not be instance of `Closure` or as a `Resource`" , E_USER_ERROR ) ; } $ quoteStr = $ this -> trimTableSelector ( $...
Alternative multi variable type quoted identifier
5,321
public function quotes ( $ quoteStr , $ type = \ PDO :: PARAM_STR ) { if ( $ quoteStr instanceof \ Closure || is_resource ( $ quoteStr ) ) { throw new \ InvalidArgumentException ( "Invalid value to be quote, quote value could not be instance of `Closure` or as a `Resource`" , E_USER_ERROR ) ; } $ quoteStr = $ this -> t...
Alternative multi variable type quote string Nested quotable
5,322
public function prefixTables ( $ table , bool $ use_identifier = false ) { if ( $ table instanceof \ Closure || is_resource ( $ table ) ) { throw new \ InvalidArgumentException ( "Invalid value to be quote, table value could not be instance of `Closure` or as a `Resource`" , E_USER_ERROR ) ; } $ prefix = $ this -> getT...
Prefixing table with predefined table prefix on configuration
5,323
public function queryBind ( string $ sql , $ statement = null ) { $ sql = $ this -> compileBindsQuestionMark ( $ sql , $ statement ) ; if ( $ sql === false ) { throw new DBALException ( sprintf ( 'Invalid statement binding count with sql query : %s' , $ sql ) , E_USER_WARNING ) ; } return $ this -> query ( $ sql ) ; }
Query using binding optionals statements
5,324
protected function tableMaybeInvalid ( $ tableName ) : string { if ( ! is_string ( $ tableName ) ) { throw new \ InvalidArgumentException ( 'Invalid table name type. Table name must be as string' , E_USER_ERROR ) ; } $ tableName = trim ( $ tableName ) ; if ( $ tableName == '' ) { throw new \ InvalidArgumentException ( ...
Check Table Maybe Invalid
5,325
public function listTableColumns ( string $ tableName ) : array { $ tableName = $ this -> tableMaybeInvalid ( $ tableName ) ; return $ this -> getSchemaManager ( ) -> listTableColumns ( $ tableName ) ; }
Get Doctrine Column of table
5,326
public function tablesExist ( $ tables ) { if ( ! is_string ( $ tables ) && ! is_array ( $ tables ) ) { throw new \ InvalidArgumentException ( 'Invalid table name type. Table name must be as string or array' , E_USER_ERROR ) ; } $ tables = $ this -> prefixTables ( $ tables ) ; ! is_array ( $ tables ) && $ tables = [ $ ...
Check if table is Exists
5,327
public function listTableDetails ( string $ tableName ) : Table { $ tableName = $ this -> tableMaybeInvalid ( $ tableName ) ; return $ this -> getSchemaManager ( ) -> listTableDetails ( $ tableName ) ; }
Get Object Doctrine Table from Table Name
5,328
public function connect ( ) { try { $ this -> pdo = new \ PDO ( $ this -> datasource -> getDsn ( ) , $ this -> datasource -> getUser ( ) , $ this -> datasource -> getPassword ( ) , $ this -> datasource -> getOption ( ) ) ; return true ; } catch ( PDOException $ e ) { throw new \ Exception ( $ e -> getMessage ( ) ) ; re...
Do a connection
5,329
public function lastInsertId ( ) { if ( $ this -> isConnected ( ) ) { try { return $ this -> pdo -> lastInsertId ( ) ; } catch ( PDOException $ e ) { throw new \ Exception ( $ e -> getMessage ( ) ) ; return false ; } } else { return false ; } }
Get last insert ID
5,330
public function query ( $ query ) { if ( $ this -> isConnected ( ) ) { try { $ statement = $ this -> pdo -> query ( $ query ) ; return new Statement ( $ statement ) ; } catch ( PDOException $ e ) { throw new \ Exception ( $ e -> getMessage ( ) ) ; return false ; } } else { return false ; } }
Executes an SQL statement and return result
5,331
private function addPropToCache ( $ propName ) { $ this -> propCache [ $ propName ] = [ 'accessors' => [ 'get' => false , 'set' => false , 'isset' => false , ] , 'type' => null , ] ; $ reflection = new \ ReflectionClass ( get_class ( $ this ) ) ; if ( $ reflection -> hasProperty ( $ propName ) ) { $ docComment = $ refl...
The method gets PHPDoc comment block of passed property and parses it . After that it defines accessibility of the property for each type of methods and pushes created structure to the cache .
5,332
public function add ( $ title ) { $ item = $ this -> menu -> addItem ( $ title ) ; $ item -> parent_id = $ this -> id ; $ item -> parent = $ this ; return $ item ; }
Add a menu item as a child .
5,333
public function children ( $ depth = false ) { return $ this -> menu -> whereParentId ( $ this -> id , $ depth ) -> all ( ) ; }
Returns children of the item .
5,334
public function action ( $ name , ... $ parameters ) { $ this -> link_type = self :: LINK_ACTION ; $ this -> link_value = [ $ name , $ parameters ] ; $ this -> checkActive ( ) ; return $ this ; }
Set the item to be a action .
5,335
public function route ( $ name , $ parameters = [ ] ) { $ this -> link_type = self :: LINK_ROUTE ; $ this -> link_value = [ $ name , $ parameters ] ; $ this -> checkActive ( ) ; return $ this ; }
Set the item to be a route .
5,336
public function url ( $ url , ... $ parameters ) { $ this -> link_type = self :: LINK_URL ; $ this -> link_value = [ $ url , $ parameters ] ; $ this -> checkActive ( ) ; return $ this ; }
Set the item to be a url .
5,337
public function insecureUrl ( $ url , ... $ parameters ) { $ this -> link_type = self :: LINK_INSECURE_URL ; $ this -> link_value = [ $ url , $ parameters ] ; $ this -> checkActive ( ) ; return $ this ; }
Set the item to be a insecure url .
5,338
public function externalUrl ( $ url ) { $ this -> link_type = self :: LINK_EXTERNAL_URL ; $ this -> link_value = [ $ url ] ; $ this -> setOpenNewWindowOption ( ) ; $ this -> setActive ( false ) ; return $ this ; }
Set the item be an external url .
5,339
private function checkActive ( $ update_parents = true ) { $ this -> setActive ( $ this -> generateUrl ( ) == \ Request :: url ( ) , $ update_parents ) ; return $ this ; }
Check and activate or deactivate .
5,340
public function setActive ( $ active = true , $ update_parents = true ) { $ this -> data [ 'active' ] = $ active ; $ method_name = $ active ? 'add' : 'remove' ; $ method_name .= $ this -> getActiveOnLinkOption ( ) ? 'Link' : 'Item' ; $ method_name .= 'Attribute' ; $ this -> $ method_name ( 'class' , 'active' ) ; if ( $...
Set this item active .
5,341
public function setHtml ( $ template , ... $ replacements ) { $ this -> data [ 'html' ] = count ( $ replacements ) ? sprintf ( $ template , ... $ replacements ) : $ template ; return $ this ; }
Check the html content for sprintf template before allocation .
5,342
private function generateUrl ( ) { $ url = '' ; switch ( $ this -> link_type ) { case self :: LINK_ACTION : $ url = action ( ... $ this -> link_value ) ; break ; case self :: LINK_ROUTE : $ url = route ( ... $ this -> link_value ) ; break ; case self :: LINK_URL : $ url = env ( 'APP_NO_SSL' , true ) ? url ( ... $ this ...
Generate the url for this item .
5,343
public static function activateIfItemIsActive ( $ item ) { if ( empty ( $ list = $ item -> getActiveIfItemIsActiveOption ( ) ) ) { return false ; } if ( ! is_array ( $ list ) ) { $ list = [ $ list ] ; } $ list [ 'self' ] = [ ] ; foreach ( $ list as $ key => $ value ) { if ( is_int ( $ key ) ) { $ list [ 'self' ] [ ] = ...
Activate if listed is item is active .
5,344
public function checkItemIsActive ( $ item ) { if ( $ this -> getActive ( ) ) { return true ; } if ( empty ( $ item_list = $ item -> getHideIfItemNotActiveOption ( ) ) ) { return true ; } if ( ! is_array ( $ item_list ) ) { $ item_list = [ $ item_list ] ; } foreach ( $ item_list as $ nickname ) { $ check_item = $ item ...
Check if listed items are active .
5,345
public function makeDropdown ( $ menu_source , $ config = [ ] ) { if ( ! is_array ( $ menu_source ) ) { $ menu_source = [ $ menu_source ] ; } $ menu_container = '' ; foreach ( $ menu_source as $ menu_name ) { $ menu = app ( 'Nav' ) -> get ( $ menu_name ) ; if ( is_null ( $ menu ) || empty ( $ menu ) ) { continue ; } $ ...
Add menu as a dropdown .
5,346
public function can ( $ ability , $ model , $ user = false ) { if ( $ user === false ) { $ user = auth ( ) -> user ( ) ; } $ this -> authorized = $ user -> can ( $ ability , $ model , $ user ) ; return $ this ; }
Check if user can use this menu item .
5,347
public function searchAndReplace ( $ str ) { $ this -> matcher -> load ( $ str , $ this -> collection ) ; return $ this -> matcher -> searchAndReplace ( ) ; }
Uses the matcher and Replacement classes to search for matches and systematically replace them .
5,348
public static function find_one_by ( $ column , $ value = null , $ operator = '=' ) { $ config = array ( 'limit' => 1 , ) ; if ( is_array ( $ column ) or ( $ column instanceof \ Closure ) ) { $ config [ 'where' ] = $ column ; } else { $ config [ 'where' ] = array ( array ( $ column , $ operator , $ value ) ) ; } $ resu...
Finds a row with the given column value .
5,349
public static function find ( $ config = array ( ) , $ key = null ) { $ query = \ DB :: select ( ) -> from ( static :: $ _table_name ) -> as_object ( get_called_class ( ) ) ; if ( $ config instanceof \ Closure ) { $ config ( $ query ) ; } else { $ config = $ config + array ( 'select' => array ( static :: $ _table_name ...
Finds all records .
5,350
public static function count ( $ column = null , $ distinct = true , $ where = array ( ) , $ group_by = null ) { $ select = $ column ? : static :: primary_key ( ) ; $ connection = static :: get_connection ( ) ; $ columns = \ DB :: expr ( 'COUNT(' . ( $ distinct ? 'DISTINCT ' : '' ) . \ Database_Connection :: instance (...
Count all of the rows in the table .
5,351
protected static function get_connection ( $ writeable = false ) { if ( $ writeable and isset ( static :: $ _write_connection ) ) { return static :: $ _write_connection ; } return isset ( static :: $ _connection ) ? static :: $ _connection : null ; }
Get the connection to use for reading or writing
5,352
public function set ( array $ data ) { foreach ( $ data as $ key => $ value ) { if ( isset ( static :: $ _mass_whitelist ) ) { in_array ( $ key , static :: $ _mass_whitelist ) and $ this -> _data [ $ key ] = $ value ; } elseif ( isset ( static :: $ _mass_blacklist ) ) { ( ! in_array ( $ key , static :: $ _mass_blacklis...
Sets an array of values to class properties
5,353
public function delete ( ) { $ this -> frozen ( true ) ; $ query = \ DB :: delete ( static :: $ _table_name ) -> where ( static :: primary_key ( ) , '=' , $ this -> { static :: primary_key ( ) } ) ; $ this -> pre_delete ( $ query ) ; $ result = $ query -> execute ( static :: get_connection ( true ) ) ; return $ this ->...
Deletes this record and freezes the object
5,354
public function frozen ( $ frozen = null ) { if ( $ frozen === null ) { return $ this -> _is_frozen ; } $ this -> _is_frozen = ( bool ) $ frozen ; return $ this ; }
Either checks if the record is frozen or sets whether it is frozen or not .
5,355
public function validation ( ) { if ( ! $ this -> _validation ) { $ this -> _validation = \ Validation :: forge ( \ Str :: random ( 'alnum' , 32 ) ) ; if ( isset ( static :: $ _rules ) and count ( static :: $ _rules ) ) { foreach ( static :: $ _rules as $ field => $ rules ) { $ label = ( isset ( static :: $ _labels ) a...
Returns the a validation object for the model .
5,356
public function validates ( ) { if ( ! isset ( static :: $ _rules ) or count ( static :: $ _rules ) < 0 ) { return true ; } $ vars = $ this -> _data ; isset ( static :: $ _defaults ) and $ vars = $ vars + static :: $ _defaults ; $ vars = $ this -> pre_validate ( $ vars ) ; return $ this -> run_validation ( $ vars ) ; }
Returns wether the instance will pass validation .
5,357
public function addFilters ( $ position , $ filters ) { if ( ! in_array ( $ position , array ( 'pre' , 'post' ) ) ) { throw new \ InvalidArgumentException ( "Cannot add filters to '$position'. Use 'pre' or 'post'" ) ; } if ( is_callable ( $ filters ) ) { $ filters = array ( $ filters ) ; } $ var = $ position . 'Filters...
Add multiple filters at once
5,358
public function applyFilter ( $ position , $ input ) { if ( ! in_array ( $ position , array ( 'pre' , 'post' ) ) ) { throw new \ InvalidArgumentException ( "Cannot add filters to '$position'. Use 'pre' or 'post'" ) ; } $ var = $ position . 'Filters' ; if ( ! $ this -> $ var ) { return $ input ; } foreach ( $ this -> $ ...
Runs filter on input
5,359
protected function generatePath ( TreeNodeInterface $ node , $ parameters ) { if ( $ this -> requestContext -> getParameter ( '_preview' ) || isset ( $ parameters [ '_preview' ] ) ) { return $ this -> generatePreviewPath ( $ node , $ parameters ) ; } $ pathGenerator = new PathGenerator ( ) ; $ path = $ pathGenerator ->...
Generate path .
5,360
public function matchRoute ( ) { $ RouteMatch = ( ArrayHelper :: KeyExists ( $ this -> UrlParserObjectInstance -> getController ( ) , $ this -> definedRoutesArray ) -> get ( ) ) ? true : false ; if ( $ RouteMatch ) { $ this -> routeName = $ this -> UrlParserObjectInstance -> getController ( ) ; $ this -> routeMetaData ...
This methods launches the routing functionality of this class
5,361
public function setController ( ) { $ routeMetaDataArray = ArrayHelper :: parts ( $ this -> pattern , $ this -> routeMetaData ) -> clean ( ) -> trim ( ) -> get ( ) ; try { if ( ! ( int ) ArrayHelper :: KeyExists ( 0 , $ routeMetaDataArray ) -> get ( ) || empty ( $ routeMetaDataArray [ 0 ] ) ) { throw new RouteException...
This method sets the controller value for this url instance
5,362
public function setMethod ( ) { if ( is_null ( $ this -> methodMetaData ) ) { $ requestParamKeys = ArrayHelper :: parts ( $ this -> urlParameterSeparator , $ this -> controller ) -> clean ( ) -> trim ( ) -> get ( ) ; if ( count ( $ requestParamKeys ) > 1 ) { $ this -> controller = $ requestParamKeys [ 0 ] ; $ this -> m...
This method sets the value of the method name
5,363
public function setParameters ( ) { $ this -> parameters = $ this -> UrlParserObjectInstance -> getParameters ( ) ; Input :: setGet ( ) -> setPost ( ) ; return $ this ; }
This method sets the value of the request parameter
5,364
public function findRootContainer ( ) : DelegateInterface { $ obj = $ this ; while ( $ obj -> hasParent ( ) === true ) { $ obj = $ obj -> getParent ( ) ; } return $ obj ; }
Moves up in the delegate hierarchy until it finds a container wihout a parent then returns that container
5,365
public function setAsChildContainerOf ( DelegateInterface $ parentContainer ) : DelegateInterface { $ this -> setParentContainer ( $ parentContainer ) ; $ parentContainer -> addChildContainer ( $ this ) ; return $ this ; }
Sets the current container to be a child container of a container
5,366
public function setAsParentContainerOf ( DelegateInterface $ childContainer ) : DelegateInterface { $ this -> addChildContainer ( $ childContainer ) ; $ childContainer -> setParentContainer ( $ this ) ; return $ this ; }
Sets the current container to be the parent container of the container passed .
5,367
public function alterQueryBuilderWithParentRoot ( $ query , $ parent_id , $ include_parent = true ) { if ( is_null ( $ parent_id ) ) { return $ query ; } $ parent = $ this -> find ( $ parent_id ) ; $ query -> andWhere ( $ query -> getRootAliases ( ) [ 0 ] . '.lft >=' . $ this -> addNamedParameter ( 'lft' , $ parent -> ...
Modify Base Query with custom options for elements from parent node
5,368
public function alterQueryBuilderExceptWithParentRoot ( $ query , $ parent_id ) { if ( is_null ( $ parent_id ) ) { return $ query ; } $ parent = $ this -> find ( $ parent_id ) ; $ query -> andWhere ( $ query -> getRootAliases ( ) [ 0 ] . '.lft > ' . $ this -> addNamedParameter ( 'rgt' , $ parent -> getRgt ( ) , $ query...
Modify Base Query with custom options for elements except from parent node
5,369
public function createQueryBuilderWithParentRoot ( $ parent_id , $ include_parent = true ) { $ query = $ this -> createQueryBuilder ( ) ; return $ this -> alterQueryBuilderWithParentRoot ( $ query , $ parent_id , $ include_parent ) ; }
Create Base Query with custom options for elements from parent node
5,370
protected function createBaseRootElement ( ) { $ root = $ this -> createNewInstance ( ) ; $ root -> setIsRoot ( true ) ; $ root -> setName ( '_ROOT_' . strtoupper ( $ this -> getResourceName ( ) ) ) ; $ root -> setTitle ( '_ROOT_' . strtoupper ( $ this -> getResourceName ( ) ) ) ; $ root -> setDescription ( 'ROOT node ...
Create a base root element
5,371
protected function findBaseRootElementOrNull ( ) { $ qb = parent :: createBaseQueryBuilder ( ) ; $ qb -> andWhere ( $ qb -> getRootAliases ( ) [ 0 ] . '.isRoot = 1' ) ; $ qb -> andWhere ( $ qb -> getRootAliases ( ) [ 0 ] . '.parent IS NULL' ) ; $ root = $ qb -> getQuery ( ) -> getOneOrNullResult ( ) ; return $ root ; }
Find an unique root element or null
5,372
public function updateLevelForChildrenElements ( $ object ) { $ tmp = new \ Doctrine \ Common \ Collections \ ArrayCollection ( ) ; $ children = $ this -> findChildrenByParentId ( $ object -> getId ( ) ) ; foreach ( $ children as $ ch ) { $ tmp -> add ( $ ch ) ; } while ( ! $ tmp -> isEmpty ( ) ) { $ d = $ tmp -> first...
Actualiza los niveles de todos los elementos
5,373
protected function updateLftRgtForAllElements_Deep_Recursive_Course ( $ object , $ cont ) { $ cont ++ ; $ object -> setLft ( $ cont ) ; $ children = $ this -> findChildrenByParentId ( $ object -> getId ( ) ) ; foreach ( $ children as $ ch ) { $ cont = $ this -> updateLftRgtForAllElements_Deep_Recursive_Course ( $ ch , ...
Actualiza de forma recursiva las posiciones lft y rgt de los nodos
5,374
public function validateRules ( ) { $ input = request ( ) -> all ( ) ; $ rules = [ ] ; $ messages = [ ] ; if ( $ this -> formRequest ) { $ this -> formRequest = new $ this -> formRequest ; $ rules = $ this -> formRequest -> rules ( ) ; $ messages = $ this -> formRequest -> messages ( ) ; } return Validator :: make ( $ ...
Validate rules from a FormRequest instance .
5,375
public function checkViewExists ( $ view ) { if ( ! View :: exists ( $ view ) ) { if ( Lang :: has ( 'resource-controller.viewnotfound' ) ) { $ message = trans ( 'resource-controller.viewnotfound' , [ 'view' => '$view' ] ) ; } else { $ message = 'Requested page couldn\'t be loaded because the view file is missing: ' . ...
Throw an exception if the view doesn t exist .
5,376
public function findFirstByKey ( $ key ) { if ( $ this -> useSoftDeletes ) { return $ this -> repository -> withTrashed ( ) -> where ( $ this -> repository -> getRouteKeyName ( ) , $ key ) -> first ( ) ; } return $ this -> repository -> findBy ( $ this -> repository -> getRouteKeyName ( ) , $ key ) ; }
Find first by key .
5,377
public function getItemsCollection ( $ orderBy = 'updated_at' , $ order = 'desc' ) { if ( $ this -> useSoftDeletes ) { return $ this -> repository -> withTrashed ( ) -> orderBy ( $ orderBy , $ order ) -> get ( ) ; } return $ this -> repository -> orderBy ( $ orderBy , $ order ) -> get ( ) ; }
Get items collection .
5,378
public function getPaginatorInstance ( $ orderBy = 'updated_at' , $ order = 'desc' ) { if ( $ this -> useSoftDeletes ) { return $ this -> repository -> withTrashed ( ) -> orderBy ( $ orderBy , $ order ) -> paginate ( ) ; } return $ this -> repository -> orderBy ( $ orderBy , $ order ) -> paginate ( ) ; }
Get Paginator instance .
5,379
public function getViewLocation ( $ action ) { if ( request ( ) -> ajax ( ) ) { return $ this -> module . $ this -> theme . $ this -> resourceName . 'ajax.' . $ action ; } return $ this -> module . $ this -> theme . $ this -> resourceName . $ action ; }
Get view location for the specified action .
5,380
public function redirectBackWithErrors ( $ validator ) { if ( request ( ) -> wantsJson ( ) ) { return $ this -> validUnprocessableEntityJsonResponse ( $ validator -> errors ( ) ) ; } return back ( ) -> withErrors ( $ validator ) -> withInput ( ) ; }
Redirect back with errors .
5,381
private function _checkRepositoryProperty ( ) { if ( ! $ this -> repository ) { if ( Lang :: has ( 'resource-controller.propertynotset' ) ) { $ message = trans ( 'resource-controller.propertynotset' , [ 'property' => '$repository' ] ) ; } else { $ message = '$repository property must be set.' ; } throw new ResourceCont...
Throw an exception if repository property is not set .
5,382
public function install ( ) { $ sql = 'CREATE TABLE IF NOT EXISTS `' . self :: TABLENAME . '` (`id` varchar(32) NOT NULL, PRIMARY KEY (`id`), `session_data` longtext NULL, `access` int(10) NULL);' ; return $ this -> app [ 'db' ] -> raw ( $ sql ) -> execute ( ) instanceof PDOStatement ; }
Installs schema for handling sessions in a database .
5,383
public function read ( $ id ) { return $ this -> app [ 'db' ] -> select ( 'session_data' ) -> from ( self :: TABLENAME ) -> where ( 'id' , $ id ) -> scalar ( ) ; }
Reads a session .
5,384
public function write ( $ id , $ data ) { $ this -> app [ 'db' ] -> delete ( self :: TABLENAME ) -> where ( 'id' , $ id ) -> execute ( ) ; return $ this -> app [ 'db' ] -> insert ( [ 'id' => $ id , 'access' => time ( ) , 'session_data' => $ data , ] ) -> into ( self :: TABLENAME ) -> execute ( ) instanceof PDOStatement...
Writes a session .
5,385
public function gc ( $ max ) { $ ttl = time ( ) - $ max ; return $ this -> app [ 'db' ] -> delete ( self :: TABLENAME ) -> where ( 'access' , $ ttl , '<' ) -> execute ( ) instanceof PDOStatement ; }
Performs garbage collection on sessions .
5,386
public function add ( EntityInterface $ token ) { if ( ! is_a ( $ token , self :: ACCESS_ENTITY_TYPE ) ) { throw new Exception ( 'The given entity (' . get_class ( $ token ) . ') is not compatible with this data source (' . self :: class . '.' ) ; } if ( $ this -> accessControlManager -> hasAccessEntityForName ( self :...
Adds the given token to the access entities
5,387
public function update ( EntityInterface $ token ) { if ( ! is_a ( $ token , self :: ACCESS_ENTITY_TYPE ) ) { throw new Exception ( 'The given entity (' . get_class ( $ token ) . ') is not compatible with this data source (' . self :: class . '.' ) ; } if ( ! $ this -> accessControlManager -> hasAccessEntityForUuid ( s...
Updates the given token
5,388
public function delete ( EntityInterface $ token ) { if ( ! is_a ( $ token , self :: ACCESS_ENTITY_TYPE ) ) { throw new Exception ( 'The given entity (' . get_class ( $ token ) . ') is not compatible with this data source (' . self :: class . '.' ) ; } if ( ! $ this -> accessControlManager -> hasAccessEntityForUuid ( s...
Deletes the token with the given uuid
5,389
public function hasTokenForPublicKey ( $ publicKey ) { if ( $ this -> accessControlManager -> hasAccessEntityForName ( self :: ACCESS_ENTITY_TYPE , $ publicKey ) ) { return true ; } return false ; }
Returns true if the given public key exists as access entity
5,390
public function getTokenForPublicKey ( $ publicKey ) { if ( ! $ this -> accessControlManager -> hasAccessEntityForName ( self :: ACCESS_ENTITY_TYPE , $ publicKey ) ) { return false ; } $ accessEntity = $ this -> accessControlManager -> getAccessEntityForName ( self :: ACCESS_ENTITY_TYPE , $ publicKey ) ; if ( $ accessE...
Returns the token object for the given public key
5,391
public function findDistinct ( $ distinct ) { $ this -> _detectEntity ( $ distinct ) ; $ this -> _distinct = $ distinct ; $ this -> _type = self :: QUERY_DISTINCT ; $ this -> _getSelect ( ) ; return $ this ; }
create a select distinct query
5,392
protected function _getTableEntity ( $ entity = '' ) { $ entity = ucfirst ( preg_replace_callback ( "/(?:^|_)([a-z])/" , function ( $ matches ) { return strtoupper ( $ matches [ 1 ] ) ; } , $ entity ) ) ; $ className = '\Orm\Entity\\' . ucfirst ( $ entity ) ; if ( class_exists ( $ className ) ) { return self :: Entity ...
return an Entity from his name
5,393
public function findRaw ( $ query ) { $ this -> _type = self :: QUERY_RAW ; $ this -> _query = $ query ; return $ this ; }
create a query without sql completion
5,394
public function fetch ( $ return = self :: RETURN_COLLECTION ) { foreach ( $ this -> _entities as $ entity ) { $ class = $ this -> _getTableEntity ( $ entity ) ; if ( $ entity != $ class -> name ( ) ) { $ this -> _query = preg_replace ( '#(.*)' . $ entity . '\.(.*)#isU' , '$1' . $ class -> name ( ) . '.$2' , $ this -> ...
fetch the current query
5,395
protected function _getEntityName ( $ entity = '' ) { $ entity = ucfirst ( preg_replace_callback ( "/(?:^|_)([a-z])/" , function ( $ matches ) { return strtoupper ( $ matches [ 1 ] ) ; } , $ entity ) ) ; $ className = '\Orm\Entity\\' . ucfirst ( $ entity ) ; if ( class_exists ( $ className ) ) { return $ entity ; } els...
return an Entity name
5,396
protected function _dataOneToMany ( $ field , $ collection ) { $ in = '' ; $ inVars = [ ] ; $ currentField = $ field -> foreign -> field ( ) ; $ referenceEntity = $ field -> foreign -> referenceEntity ( ) ; $ referenceField = $ field -> foreign -> referenceField ( ) ; $ fieldFormName = lcfirst ( $ referenceEntity ) . '...
If the Entity has at least one to many relation we had a collection to the right field
5,397
protected function _dataManyToMany ( $ field , $ collection ) { $ in = '' ; $ inVars = [ ] ; $ currentEntity = $ field -> foreign -> entity ( ) ; $ currentField = $ this -> _entity -> primary ( ) ; $ referenceEntity = $ field -> foreign -> referenceEntity ( ) ; $ referenceField = $ field -> foreign -> referenceField ( ...
If the Entity has at least many to many relation we had a collection to the right field
5,398
public static function getHook ( $ action , $ noPriv = false ) { return ( $ noPriv ? self :: WP_AJAX_NOPRIV_HOOK_PREFIX : self :: WP_AJAX_HOOK_PREFIX ) . $ action ; }
Gets the action hook string to use based on the action name that was provided
5,399
public static function register ( $ action , $ callable , $ noPriv = false ) { if ( ! $ noPriv || $ noPriv === self :: REGISTER_BOTH ) add_action ( self :: getHook ( $ action ) , $ callable ) ; if ( $ noPriv || $ noPriv === self :: REGISTER_BOTH ) add_action ( self :: getHook ( $ action , true ) , $ callable ) ; }
Binds the callable to the given hook