idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
7,600
public function getUserGroups ( $ lang = "" ) { if ( ! User :: hasAccess ( 'Permissions' , 'read' ) ) { return $ this -> noPermission ( ) ; } return array ( 'data' => \ App \ Models \ UserGroup :: all ( ) ) ; }
All users group
7,601
public function delete ( $ lang , $ id ) { if ( ! User :: hasAccess ( 'Permissions' , 'delete' ) ) { return $ this -> noPermission ( ) ; } DB :: statement ( 'SET FOREIGN_KEY_CHECKS=0' ) ; $ group = \ App \ Models \ UserGroup :: find ( $ id ) -> delete ( ) ; if ( $ group ) { DB :: table ( 'permissions' ) -> where ( 'gro...
Delete a group and it s permissions by it s ID .
7,602
public function store ( Request $ request ) { if ( ! User :: hasAccess ( 'Permissions' , 'create' ) ) { return $ this -> noPermission ( ) ; } $ messages = array ( 'id.required' => 'ID is missing' , 'name.required' => 'You cant leave name field empty' , 'permissions.required' => 'Something is wrong, please contact your ...
Creates or Updates group and permissions .
7,603
public function bulkDelete ( Request $ request ) { if ( ! User :: hasAccess ( 'Permissions' , 'delete' ) ) { return $ this -> noPermission ( ) ; } $ data = $ request -> all ( ) ; if ( isset ( $ data [ 'postTypes' ] ) ) { unset ( $ data [ 'postTypes' ] ) ; } DB :: statement ( 'SET FOREIGN_KEY_CHECKS=0' ) ; foreach ( $ d...
Bulk Delete groups and permissions delete many groups in one request .
7,604
public function getList ( Request $ request ) { if ( ! User :: hasAccess ( 'permissions' , 'read' ) ) { return $ this -> noPermission ( ) ; } $ className = 'App\\Models\\' . $ request -> customPermissions [ 'model' ] ; $ class = new $ className ( ) ; $ currentLang = App :: getLocale ( ) ; $ obj = DB :: table ( $ class ...
USED to get list of models for custom permissions . Returns array list from DB with primary key as array key and selected columns as value .
7,605
protected function getAllowedMethods ( $ item ) { $ cls = get_class ( $ item ) ; $ allowed = isset ( $ this -> allowedMethods [ $ cls ] ) ? $ this -> allowedMethods [ $ cls ] : null ; if ( ! $ allowed ) { $ conf = Config :: inst ( ) -> get ( get_class ( $ item ) , 'allowed_template_methods' ) ; if ( $ conf ) { $ allowe...
Gets the list of methods that can be called from a template .
7,606
public function onInitialize ( ResourceEventInterface $ event ) { $ page = $ this -> getPageFromEvent ( $ event ) ; $ parent = $ page -> getParent ( ) ; if ( $ parent && $ parent -> isLocked ( ) ) { throw new RuntimeException ( "Cannot create child page under a locked parent page." ) ; } }
Initialize event handler .
7,607
private function deletePageCache ( PageInterface $ page ) { if ( null !== $ this -> cache ) { $ this -> cache -> delete ( 'ekyna_cms.page[route:' . $ page -> getRoute ( ) . ']' ) ; } }
Saves the page in doctrine cache .
7,608
private function disablePageChildren ( PageInterface $ page ) { $ childrenDisabled = false ; if ( ! $ page -> isEnabled ( ) ) { if ( 0 < $ page -> getChildren ( ) -> count ( ) ) { foreach ( $ page -> getChildren ( ) as $ child ) { if ( $ child -> isEnabled ( ) ) { $ child -> setEnabled ( false ) ; $ childrenDisabled = ...
Disables the page children if needed .
7,609
private function disablePageRelativeMenus ( PageInterface $ page ) { $ disabledMenus = false ; if ( ! $ page -> isEnabled ( ) ) { $ disableChildrenQuery = $ this -> em -> createQuery ( sprintf ( 'UPDATE %s m SET m.enabled = 0 WHERE m.root = :root AND m.left > :left AND m.right < :right' , $ this -> menuClass ) ) ; $ me...
Disable the page relative menus if needed .
7,610
private function getPageFromEvent ( ResourceEventInterface $ event ) { $ resource = $ event -> getResource ( ) ; if ( ! $ resource instanceof PageInterface ) { throw new InvalidArgumentException ( "Expected instance of PageInterface" ) ; } return $ resource ; }
Returns the page from the event .
7,611
public function statusCodeAction ( $ code = null , $ message = null ) { $ codes = [ 403 => "403 Forbidden" , 404 => "404 Not Found" , 500 => "500 Internal Server Error" , ] ; if ( ! $ code || ! in_array ( $ code , $ codes ) ) { throw new \ Anax \ Exception \ NotFoundException ( "Not a valid HTTP status code." ) ; } $ t...
Display a page for a HTTP status code .
7,612
public function displayValidRoutesAction ( ) { $ this -> di -> views -> add ( 'default/error-routes' , [ 'route' => $ this -> di -> request -> getRoute ( ) , 'routes' => $ this -> di -> router -> getAll ( ) , 'internalRoutes' => $ this -> di -> router -> getInternal ( ) , 'controllers' => $ this -> di -> getControllers...
Display a list of valid routes .
7,613
function action_delete ( $ param = null ) { if ( ! isset ( $ this -> model ) ) throw new FlashMessageException ( 'Can\'t delete a NULL model.' , FlashType :: ERROR ) ; throw new FlashMessageException ( sprintf ( 'Can\'t automatically delete object of type <kbd>%s</kbd>' , gettype ( $ this -> model ) ) , FlashType :: ER...
Responds to the standard delete controller action . The default procedure is to delete the object on the database . Override to implement non - standard behaviour .
7,614
function action_submit ( $ param = null ) { if ( ! isset ( $ this -> model ) ) throw new FlashMessageException ( 'Can\'t insert/update a NULL model.' , FlashType :: ERROR ) ; throw new FlashMessageException ( 'Can\'t automatically insert/update an object of type ' . gettype ( $ this -> model ) , FlashType :: ERROR ) ; ...
Responds to the standard submit controller action . The default procedure is to throw an error message . Override to implement the desired behaviour .
7,615
protected function doFormAction ( ) { $ this -> getActionAndParam ( $ action , $ param ) ; $ class = new ReflectionObject ( $ this ) ; try { $ method = $ class -> getMethod ( 'action_' . $ action ) ; } catch ( ReflectionException $ e ) { throw new FlashMessageException ( 'Class <b>' . $ class -> getName ( ) . "</b> can...
Invokes the right controller method in response to the POST request s specified action .
7,616
protected function defineStrategyHandlers ( ) { if ( ! $ this -> _strategiesDefined ) { foreach ( $ this -> getStrategies ( ) as $ strategyClass ) { $ strategyMethod = 'handleStrategy' . $ strategyClass ; $ this -> addWrapperMethod ( $ strategyMethod , 'handleStrategy' ) ; } $ this -> _strategiesDefined = true ; } }
Channel several unknown strategies in to one handler
7,617
protected function getActions ( ) { $ actions = new FieldList ( ) ; foreach ( $ this -> getStrategies ( ) as $ strategyClass ) { $ strategyMethod = 'handleStrategy' . $ strategyClass ; $ fa = new FormAction ( $ strategyMethod , $ strategyClass ) ; $ fa -> setUseButtonTag ( true ) ; $ actions -> push ( $ fa ) ; } return...
Provide an action button to be clicked per strategy
7,618
public function handleStrategy ( $ funcName , $ data , $ form , $ request ) { if ( func_num_args ( ) < 4 ) { throw new LogicException ( 'Must be called with a strategy handler' ) ; } $ strategy = substr ( $ funcName , strlen ( 'handleStrategy' ) ) . 'Strategy' ; if ( ! class_exists ( $ strategy ) || $ strategy instance...
Global endpoint for handleStrategy - all strategy actions point here .
7,619
public function setContent ( string $ content = null ) : ResponseContextAbstract { if ( is_null ( $ content ) ) { return $ this ; } $ this -> assertIsValid ( $ content ) ; $ this -> content = $ content ; return $ this ; }
Set result content .
7,620
public function hasHttpError ( ) : bool { $ httpStatus = new NanoHttpStatus ( ) ; return $ httpStatus -> isClientError ( $ this -> httpStatusCode ) || $ httpStatus -> isServerError ( $ this -> httpStatusCode ) ; }
Returns if current response context has HTTP error status code set
7,621
public static function getByType ( string $ type , string $ content = null ) : ResponseContextAbstract { switch ( $ type ) { case self :: RESPONSE_TYPE_JSON : return new JsonResponseContext ( $ content ) ; default : return new DummyResponseContext ( $ content ) ; } }
Create response context instance
7,622
public function getUniqueReference ( ) { if ( $ this -> uniqueReference === null ) { $ modelName = basename ( str_replace ( "\\" , "/" , $ this -> getModelClassName ( ) ) ) ; if ( ! isset ( self :: $ uniqueReferencesUsed [ $ modelName ] ) ) { self :: $ uniqueReferencesUsed [ $ modelName ] = 0 ; } self :: $ uniqueRefere...
Gets the unique reference for this collection .
7,623
public function getRepository ( ) { $ emptyObject = SolutionSchema :: getModel ( $ this -> modelClassName ) ; $ repository = $ emptyObject -> getRepository ( ) ; return $ repository ; }
Gets the repository used by the associated data object .
7,624
final public function addSort ( $ columnName , $ ascending = true ) { $ parts = explode ( "." , $ columnName ) ; $ sort = new Sort ( ) ; if ( count ( $ parts ) > 1 ) { $ columnName = $ parts [ count ( $ parts ) - 1 ] ; $ relationships = array_slice ( $ parts , 0 , count ( $ parts ) - 1 ) ; $ newColumnName = PdoReposito...
Adds another sort condition .
7,625
final public function replaceSort ( $ columnName , $ ascending = true ) { if ( ! is_array ( $ columnName ) ) { $ sorts = [ $ columnName => $ ascending ] ; } else { $ sorts = $ columnName ; } $ this -> sorts = [ ] ; foreach ( $ sorts as $ index => $ value ) { $ this -> addSort ( $ index , $ value ) ; } return $ this ; }
Removes current sorts and replaces with another .
7,626
public function append ( Model $ model ) { $ result = null ; if ( $ this -> filter !== null ) { $ result = $ this -> filter -> setFilterValuesOnModel ( $ model ) ; } $ model -> save ( ) ; $ this -> invalidate ( ) ; return ( $ result === null ) ? $ model : $ result ; }
Append a model to the list and correctly set any fields required to make this re - fetchable through the same list .
7,627
final public function intersectWith ( Collection $ collection , $ sourceColumnName , $ targetColumnName , $ columnsToPullUp = [ ] , $ autoHydrate = false ) { $ collection -> isIntersection = true ; $ collectionJoin = new CollectionJoin ( $ collection , $ sourceColumnName , $ targetColumnName , $ columnsToPullUp , $ aut...
Create an intersection with a second collection .
7,628
public function joinWith ( Collection $ collection , $ sourceColumnName , $ targetColumnName , $ columnsToPullUp = [ ] , $ autoHydrate = false ) { $ collectionJoin = new CollectionJoin ( $ collection , $ sourceColumnName , $ targetColumnName , $ columnsToPullUp , $ autoHydrate , CollectionJoin :: JOIN_TYPE_ATTACH ) ; $...
Join a collection on to our parent collection
7,629
final public function addAggregateColumn ( Aggregate $ aggregate ) { $ parts = explode ( "." , $ aggregate -> getAggregateColumnName ( ) ) ; if ( count ( $ parts ) > 1 ) { $ columnName = $ parts [ count ( $ parts ) - 1 ] ; $ relationships = array_slice ( $ parts , 0 , count ( $ parts ) - 1 ) ; $ aggregate -> setAliasDe...
Adds the instruction to build an aggregate column .
7,630
public function batchUpdate ( $ propertyPairs , $ fallBackToIteration = false ) { try { if ( $ this instanceof RepositoryCollection ) { $ this -> getRepository ( ) -> batchCommitUpdatesFromCollection ( $ this , $ propertyPairs ) ; } else { throw new BatchUpdateNotPossibleException ( ) ; } } catch ( BatchUpdateNotPossib...
Applies the provided set of property values to all of the models in the collection .
7,631
public function filter ( ... $ filters ) { if ( sizeof ( $ filters ) == 0 ) { return $ this ; } $ andGroup = new AndGroup ( ) ; if ( is_array ( $ filters [ 0 ] ) ) { $ filters = $ filters [ 0 ] ; } foreach ( $ filters as $ filter ) { if ( ! ( $ filter instanceof Filter ) ) { throw new FilterNotSupportedException ( 'One...
filter the existing list using the supplied DataFilter .
7,632
public function setRange ( $ startIndex , $ maxItems ) { $ changed = false ; if ( sizeof ( $ this -> sorts ) == 0 ) { $ this -> addSort ( SolutionSchema :: getModelSchema ( $ this -> getModelClassName ( ) ) -> uniqueIdentifierColumnName ) ; } if ( $ this -> rangeStartIndex != $ startIndex ) { $ this -> rangeStartIndex ...
Limits the range of iteration from startIndex to startIndex + maxItems
7,633
private function getGroupKeyForModel ( Model $ model ) { $ key = "" ; foreach ( $ this -> groups as $ group ) { $ key .= $ model [ $ group ] . "|" ; } return $ key ; }
Returns a string which uniquely represents the group the given model should be in for aggregation .
7,634
private function processAggregates ( $ aggregates ) { foreach ( $ this -> collectionCursor as $ model ) { foreach ( $ aggregates as $ aggregate ) { $ aggregate -> calculateByIteration ( $ model , $ this -> getGroupKeyForModel ( $ model ) ) ; } } $ additionalData = [ ] ; foreach ( $ aggregates as $ aggregate ) { $ group...
Takes a collection of aggregate columns and calculates their value .
7,635
public function findModelByUniqueIdentifier ( $ identifier ) { $ this -> filter ( new Equals ( $ this -> getModelSchema ( ) -> uniqueIdentifierColumnName , $ identifier ) ) ; return $ this [ 0 ] ; }
Filters the collection to the given identifier .
7,636
private function filterCursor ( $ postAggregates = false ) { $ filter = $ this -> getFilter ( ) ; if ( $ filter ) { if ( $ filter -> requiresAggregation ( $ this ) && ! $ postAggregates ) { return ; } if ( ! $ filter -> requiresAggregation ( $ this ) && $ postAggregates ) { return ; } $ uniqueIdentifiersToFilter = [ ] ...
Filters the collection manually if it wasn t able to filter itself .
7,637
private function reduceCursorForGroups ( ) { $ reduceForGroups = $ groupKeys = [ ] ; $ index = 0 ; foreach ( $ this -> collectionCursor as $ model ) { $ groupKey = $ this -> getGroupKeyForModel ( $ model ) ; if ( $ groupKey != '' ) { if ( ! in_array ( $ groupKey , $ groupKeys ) ) { $ groupKeys [ ] = $ groupKey ; } else...
Removes results which should be collapsed into a single grouped result
7,638
public function addWhereExpression ( WhereExpression $ where ) { if ( ! ( $ this -> whereExpression instanceof AndExpression ) ) { $ this -> whereExpression = new AndExpression ( $ this -> whereExpression ) ; } $ andExpression = $ this -> whereExpression ; $ andExpression -> whereExpressions [ ] = $ where ; return $ an...
Add a where clause expression .
7,639
public function implodeSqlClauses ( $ clauses , $ glue = ',' ) { $ statements = [ ] ; foreach ( $ clauses as $ clause ) { $ statements [ ] = $ clause -> getSql ( $ this ) ; } return implode ( $ statements , $ glue ) ; }
Utility function to implode a sequence of Sql clauses with glue .
7,640
public function getUpdateSql ( $ fieldsToUpdate ) { $ sql = "UPDATE `" . $ this -> schemaName . "` AS `" . $ this -> getAlias ( ) . "`" ; foreach ( $ this -> joins as $ join ) { $ sql .= " " . $ join -> joinType . " (" . $ join -> getSql ( $ this ) . ") AS `" . $ join -> statement -> getAlias ( ) . "` ON `" . $ this ->...
Returns an UPDATE statement using the supplied key value pairings to update .
7,641
public function getSelectSql ( ) { $ sql = "SELECT " ; $ sql .= $ this -> implodeSqlClauses ( $ this -> columns , ", " ) . " FROM `" . $ this -> schemaName . "` AS `" . $ this -> getAlias ( ) . "`" ; foreach ( $ this -> joins as $ join ) { $ joinsSql = $ join -> getSql ( $ this ) ; if ( strpos ( $ joinsSql , " " ) !== ...
Returns the SELECT statement required to fetch the data .
7,642
public function generateAction ( $ context , $ lang , $ id ) { $ request = $ this -> getRequest ( ) ; if ( "" === $ context ) { $ context = "catalog" ; } else if ( ! in_array ( $ context , array ( "catalog" , "content" , "brand" ) ) ) { $ this -> pageNotFound ( ) ; } if ( "" !== $ lang ) { if ( ! $ this -> checkLang ( ...
render the RSS feed
7,643
protected function getCacheDir ( ) { $ cacheDir = $ this -> container -> getParameter ( "kernel.cache_dir" ) ; $ cacheDir = rtrim ( $ cacheDir , '/' ) ; $ cacheDir .= '/' . self :: FEED_CACHE_DIR . '/' ; return $ cacheDir ; }
get the cache directory for feeds
7,644
private function checkId ( $ context , $ id ) { $ ret = false ; if ( is_numeric ( $ id ) ) { if ( "catalog" === $ context ) { $ cat = CategoryQuery :: create ( ) -> findPk ( $ id ) ; $ ret = ( null !== $ cat && $ cat -> getVisible ( ) ) ; } elseif ( "brand" === $ context ) { $ brand = BrandQuery :: create ( ) -> findPk...
Check if the element exists and is visible
7,645
public function customFieldValue ( $ key ) { $ value = null ; if ( $ this -> hasCustomField ( $ key ) ) { if ( isset ( $ this -> customFields -> $ key -> { $ this -> getTranslateLanguage ( ) } ) ) { $ value = $ this -> customFields -> $ key -> { $ this -> getTranslateLanguage ( ) } ; } else { $ value = $ this -> custom...
Get custom field value by key .
7,646
public function hasCustomField ( $ key ) { if ( $ key !== 'customFields' && ! array_key_exists ( $ key , $ this -> getAttributes ( ) ) ) { if ( isset ( $ this -> customFields -> $ key ) ) { return true ; } } return false ; }
Check if a given key is a custom field .
7,647
public function getMediaFromCustomFields ( $ customFields , ... $ slugs ) { $ mediaIDs = [ ] ; foreach ( $ customFields as $ fields ) { foreach ( $ fields as $ field => $ value ) { if ( in_array ( $ field , $ slugs ) ) { if ( ! is_array ( $ value ) ) { $ mediaIDs [ ] = $ value ; } else { foreach ( $ value as $ subValue...
Replaces mediaIDs eith the actuall media object .
7,648
protected function interpolate ( array $ variables = array ( ) ) { $ template = $ this -> logFormat ; if ( ! isset ( $ variables [ 'context' ] ) ) { $ variables [ 'context' ] = '' ; } $ this -> reverseJsonInContext ( $ variables [ 'context' ] ) ; if ( ! $ variables [ 'context' ] ) { $ template = str_replace ( '%context...
Interpolates log variables into the defined log format .
7,649
protected function normalizeLevel ( $ level ) { if ( is_int ( $ level ) && array_search ( $ level , self :: $ levels ) !== false ) { return $ level ; } if ( is_string ( $ level ) && isset ( self :: $ levels [ $ level ] ) ) { return self :: $ levels [ $ level ] ; } throw new Exception ( sprintf ( "Unknown LogLevel: '%s'...
Converts a given log level to the integer form .
7,650
protected function addClass ( string $ class ) { if ( $ this -> initialized ) { throw new RuntimeException ( "You can't register provider class as registry as been initialized." ) ; } if ( ! class_exists ( $ class ) ) { throw new InvalidArgumentException ( "Class $class does not exist." ) ; } if ( ! is_subclass_of ( $ ...
Adds the given provider class .
7,651
protected function initialize ( ) { if ( $ this -> initialized ) { return ; } foreach ( $ this -> classes as $ class ) { $ this -> providers [ ] = new $ class ; } foreach ( $ this -> providers as $ provider ) { if ( $ provider instanceof BuilderAwareInterface ) { $ provider -> setSchemaBuilder ( $ this -> schemaBuilder...
Initializes the registry .
7,652
public static function replace ( $ uri , $ parameters = [ ] ) { $ parameters = ( array ) $ parameters ; $ uri = static :: replaceRouteParameters ( $ uri , $ parameters ) ; $ uri = str_replace ( '//' , '/' , $ uri ) ; return $ uri ; }
Replace route parameters .
7,653
protected static function bootBootEventsTrait ( ) { $ explode = explode ( '\\' , get_class ( ) ) ; $ modelName = lcfirst ( str_replace ( 'Model' , '' , end ( $ explode ) ) ) ; self :: saving ( function ( $ album ) use ( $ modelName ) { Event :: fire ( $ modelName . ':saving' , [ $ album ] ) ; } ) ; self :: saved ( func...
Default boot events .
7,654
private function createFolderIfNotExists ( $ cache_path ) { if ( ! is_dir ( $ cache_path ) ) { if ( false === @ mkdir ( $ cache_path , 0777 & ( ~ $ this -> umask ) , true ) && ! is_dir ( $ cache_path ) ) { return false ; } } return true ; }
Create folder or path if it is not exists .
7,655
private function deleteCacheSubfoldersIfEmpty ( $ filepath ) { if ( $ this -> cache_path == $ filepath ) { return true ; } $ filepath_exp = explode ( DIRECTORY_SEPARATOR , $ filepath ) ; if ( is_array ( $ filepath_exp ) ) { for ( $ i = count ( $ filepath_exp ) - 1 ; $ i >= 0 ; $ i -- ) { $ dir = implode ( DIRECTORY_SEP...
Delete cache sub folder recursively if empty .
7,656
private function deleteCacheSubfolderRecursively ( $ dir ) { if ( is_dir ( $ dir ) ) { $ objects = scandir ( $ dir ) ; foreach ( $ objects as $ object ) { if ( $ dir . DIRECTORY_SEPARATOR . $ object == $ this -> cache_path ) { return false ; } elseif ( $ object != '.' && $ object != '..' ) { if ( is_writable ( $ dir . ...
Delete cache files and all sub folders recursively .
7,657
private function getPath ( ) { if ( ( $ path = $ this -> config [ 'path' ] ) instanceof \ Closure ) { $ this -> line ( 'Generating dynamic download path.' ) ; $ this -> line ( '' ) ; if ( is_numeric ( $ path = $ path ( $ this ) ) ) { exit ( $ path ) ; } $ this -> line ( '' ) ; } if ( ! is_string ( $ path ) ) { $ this -...
Get path from string or via a closure .
7,658
private function downloadPath ( $ path ) { $ this -> info ( sprintf ( 'Downloading \'%s\'...' , $ path ) ) ; $ this -> line ( '' ) ; if ( stripos ( $ path , 'ftp://' ) !== false ) { return file_get_contents ( $ path ) ; } $ client = new GuzzleClient ( ) ; $ res = $ client -> request ( 'GET' , $ path ) ; $ code = $ res ...
Download the file from the path .
7,659
private function readData ( $ data ) { $ this -> line ( 'Processing...' ) ; $ this -> line ( '' ) ; $ reader = Reader :: createFromString ( $ data ) ; if ( array_has ( $ this -> config , 'filter' ) ) { $ reader = $ this -> config [ 'filter' ] ( $ reader ) ; } if ( ! array_has ( $ this -> config , 'no_header' , false ) ...
Read the data and do our mapping .
7,660
private function translateRow ( & $ row ) { $ new_row = [ ] ; foreach ( $ row as $ key => $ value ) { if ( array_has ( $ this -> config [ 'mapping' ] , $ key ) ) { $ new_row [ array_get ( $ this -> config [ 'mapping' ] , $ key ) ] = $ value ; } } $ row = $ new_row ; }
Translate the row using the configured mapping rules .
7,661
private function transformRow ( & $ row ) { if ( array_has ( $ this -> config , 'modify' ) ) { foreach ( $ row as $ key => & $ value ) { if ( array_has ( $ this -> config [ 'modify' ] , $ key ) ) { $ this -> config [ 'modify' ] [ $ key ] ( $ value , $ row ) ; } unset ( $ value ) ; } } }
Transform the row using the configured modification rules .
7,662
private function importData ( $ data ) { $ this -> line ( sprintf ( 'Importing %s records...' , count ( $ data ) ) ) ; $ this -> line ( '' ) ; $ this -> progress_bar = $ this -> output -> createProgressBar ( count ( $ data ) ) ; foreach ( $ data as $ row ) { $ this -> processImportRow ( $ row ) ; } $ this -> line ( ' ...
Import data .
7,663
private function processImportRow ( & $ row ) { $ model = $ this -> lookupModel ( $ row ) ; foreach ( $ row as $ key => $ value ) { if ( empty ( $ model -> getKey ( ) ) || $ model -> $ key !== $ value ) { $ model -> $ key = $ value ; } } $ model -> save ( ) ; $ this -> progress_bar -> advance ( ) ; }
Process the importing of the row .
7,664
private function lookupModel ( & $ row ) { $ query = new ImportModel ( ) ; $ query -> setConnection ( $ this -> connection ( $ this -> argument ( 'dataset' ) ) ) ; $ query -> setTable ( sprintf ( 'data_%s' , array_get ( $ this -> config , 'table' ) ) ) ; $ count_keys = 0 ; foreach ( array_get ( $ this -> config , 'impo...
Lookup the new or existing model for this row .
7,665
public function block ( $ messages , $ type = 'error' ) { $ output = [ ] ; if ( ! is_array ( $ messages ) ) { $ messages = ( array ) $ messages ; } foreach ( $ messages as $ message ) { $ output [ ] = trim ( $ message ) ; } $ formatter = new FormatterHelper ( ) ; $ this -> line ( $ formatter -> formatBlock ( $ output ,...
A wrapper around symfony s formatter helper to output a block .
7,666
public function connect ( $ addr = null , $ port = null , $ timeout = null ) { if ( $ port == null && $ timeout == null ) { if ( $ addr !== null ) { $ timeout = $ addr ; } else { $ timeout = 0 ; } if ( $ this -> addr == null || $ this -> port == null ) { throw new \ InvalidArgumentException ( 'Address and port were not...
Initiates a connection on this socket .
7,667
public function setBlocking ( $ blocking ) { if ( $ this -> blocking == $ blocking ) { return ; } if ( $ blocking ) { if ( @ socket_set_block ( $ this -> socket ) === false ) { $ this -> throwSocketError ( ) ; } $ this -> blocking = true ; } else { if ( @ socket_set_nonblock ( $ this -> socket ) === false ) { $ this ->...
Sets blocking mode on a socket resource
7,668
public function render ( $ templateIdent = null ) { if ( $ templateIdent === null ) { $ templateIdent = $ this -> templateIdent ( ) ; } return $ this -> view ( ) -> render ( $ templateIdent , $ this -> viewController ( ) ) ; }
Render the template by the given identifier .
7,669
public function setViewController ( $ controller ) { if ( is_scalar ( $ controller ) || is_resource ( $ controller ) ) { throw new InvalidArgumentException ( 'View controller must be an object, null or an array' ) ; } $ this -> viewController = $ controller ; return $ this ; }
Set a view controller for the template s context .
7,670
protected function createTemporaryFiles ( $ files ) { foreach ( $ files as $ file ) { if ( is_array ( $ file ) ) $ this -> createTemporaryFiles ( $ file ) ; else { do { $ dst = sys_get_temp_dir ( ) . uniqid ( ) . '.tmp' ; if ( ! file_exists ( $ dst ) ) break ; } while ( true ) ; copy ( $ file -> src ( ) , $ dst ) ; $ f...
Create temporary files .
7,671
public function setPlaceHolder ( PlaceHolder $ placeHolder ) { $ this -> placeHolder = $ placeHolder ; $ this -> placeHolder -> addBlock ( $ this ) ; }
Sets place holder
7,672
public static function factory ( Localization $ base , Block $ source = null ) { $ block = null ; switch ( $ base :: DISCRIMINATOR ) { case self :: TEMPLATE_DISCR : $ block = new TemplateBlock ( ) ; break ; case self :: PAGE_DISCR : case self :: APPLICATION_DISCR : $ block = new PageBlock ( ) ; break ; default : throw ...
Creates new instance based on the discriminator of the base entity .
7,673
public function forceLogin ( Model $ user = null ) { if ( $ user === null ) { throw new ImplementationException ( 'A model is required to force login' ) ; } $ this -> loggedInUserIdentifier = $ user -> UniqueIdentifier ; parent :: forceLogin ( ) ; }
Provides a way to set the logged in user based on having the user s model .
7,674
public function getModel ( ) { if ( ! $ this -> isLoggedIn ( ) ) { throw new NotLoggedInException ( ) ; } if ( isset ( $ this -> loggedInUserIdentifier ) ) { try { return SolutionSchema :: getModel ( $ this -> modelClassName , $ this -> loggedInUserIdentifier ) ; } catch ( RecordNotFoundException $ er ) { throw new Not...
Returns the model object for the logged in user .
7,675
public function getSingle ( ) { $ endpoint = $ this -> buildEndpoint ( ) ; $ this -> buildHttpHeader ( ) ; $ client = new Client ( ) ; try { $ response = $ client -> request ( 'GET' , $ endpoint , [ 'headers' => $ this -> headers , 'query' => [ '$select' => $ this -> select , 'id' => $ this -> recordID , ] , 'curl' => ...
Get a single record from a defined table
7,676
public function put ( ) { $ parameters = [ 'headers' => $ this -> buildHttpHeader ( ) , 'query' => [ '$select' => $ this -> select ] , 'body' => $ this -> postFields , 'curl' => $ this -> setPostCurlopts ( ) , ] ; $ results = $ this -> sendData ( 'PUT' , $ parameters ) ; $ this -> reset ( ) ; return $ results ; }
Execute a PUT request to update existing records
7,677
public function delete ( $ id ) { $ endpoint = $ this -> buildEndpoint ( ) ; $ endpoint .= '/' . $ id ; $ this -> buildHttpHeader ( ) ; $ client = new Client ( ) ; try { $ response = $ client -> request ( 'DELETE' , $ endpoint , [ 'headers' => $ this -> headers , 'curl' => $ this -> setGetCurlopts ( ) , ] ) ; } catch (...
Delete a record with the supplied ID
7,678
protected function buildEndpoint ( ) { $ endpoint = $ this -> authorization -> apiEndpoint . '/tables/' . $ this -> tableName . '/' ; if ( $ this -> recordID ) { $ endpoint .= $ this -> recordID ; } return $ endpoint ; }
Construct the API Endpoint for the request
7,679
private function reset ( ) { $ this -> tableName = null ; $ this -> select = '*' ; $ this -> filter = null ; $ this -> orderby = null ; $ this -> skip = 0 ; $ this -> groupby = null ; $ this -> having = null ; $ this -> top = null ; $ this -> distinct = null ; $ this -> recordID = null ; $ this -> postFields = null ; }
Reset query parameters
7,680
protected function close ( ) { if ( is_resource ( $ this -> stream ) ) { $ this -> flush ( ) ; fclose ( $ this -> stream ) ; } $ this -> stream = false ; }
Close the log file .
7,681
public function applyToQueryBuilder ( QueryBuilder $ qb , & $ parameterOffset = 0 ) { $ orderRules = $ this -> orderRules ; foreach ( $ orderRules as $ orderRule ) { $ field = $ orderRule [ self :: FIELD_POS ] ; switch ( $ field ) { case self :: LEFT_FIELD : case self :: RIGHT_FIELD : case self :: LEVEL_FIELD : break ;...
Add order rules to the query builder NB! The alias of the main table must be e .
7,682
public function renderContainer ( $ container , $ type = null , array $ data = [ ] ) { if ( is_string ( $ container ) ) { if ( null === $ element = $ this -> editor -> getRepository ( ) -> findContainerByName ( $ container ) ) { $ this -> persist ( $ element = $ this -> editor -> getContainerManager ( ) -> create ( $ c...
Renders the container .
7,683
public function renderRow ( $ row , array $ data = [ ] ) { if ( is_string ( $ row ) ) { if ( null === $ element = $ this -> editor -> getRepository ( ) -> findRowByName ( $ row ) ) { $ this -> persist ( $ element = $ this -> editor -> getRowManager ( ) -> create ( $ row , $ data ) ) ; } $ row = $ element ; } if ( $ row...
Renders the row .
7,684
public function renderBlock ( $ block , $ type = null , array $ data = [ ] ) { if ( is_string ( $ block ) ) { if ( null === $ element = $ this -> editor -> getRepository ( ) -> findBlockByName ( $ block ) ) { $ this -> persist ( $ element = $ this -> editor -> getBlockManager ( ) -> create ( $ block , $ type , $ data )...
Renders the block .
7,685
private function persist ( $ element ) { $ this -> manager -> persist ( $ element ) ; $ this -> manager -> flush ( $ element ) ; }
Persists the element and flushes the manager .
7,686
public static function formatLocale ( $ locale ) { if ( \ is_string ( $ locale ) ) { $ locale = strtolower ( $ locale ) ; $ locale = str_replace ( '-' , '_' , $ locale ) ; } return $ locale ; }
Format the locale .
7,687
private function findByKey ( string $ scopeKey ) : Scope { $ locales = $ this -> config -> get ( 'locales' ) ; $ locales = array_merge ( $ locales [ '*' ] , $ locales [ $ scopeKey ] ) ; return new Scope ( array_flip ( array_flip ( $ locales ) ) ) ; }
We limit the available locales to the current domain space including the default ones
7,688
protected function checkList ( $ item ) { $ inList = in_array ( $ item , $ this -> list ) ; $ allow = null ; if ( $ this -> mode == self :: MODE_BLACKLIST ) { $ allow = ! $ inList ; } else { $ allow = $ inList ; } return $ allow ; }
Checks if item is in list
7,689
protected function processRaw ( Request $ request ) { $ resolver = $ this -> getResolver ( ) ; $ resolver -> sortRoutes ( ) ; $ route = $ resolver -> getRoute ( $ request ) ; if ( $ route ) { $ request -> setRoute ( $ route ) ; $ controllerClass = $ route -> getController ( ) ; $ action = $ route -> getAction ( ) ; $ c...
Return a raw response .
7,690
protected function getExceptionResponse ( $ e ) { while ( ob_get_level ( ) > $ this -> startObLevel ) ob_end_clean ( ) ; $ this -> errorHandler -> exceptionHandler ( $ e ) ; $ trace = $ this -> errorHandler -> getBacktraceFromException ( $ e ) ; if ( $ e instanceof \ Asgard \ Debug \ PSRException ) $ msg = $ e -> getMe...
Get a response from an exception .
7,691
protected function executeStart ( Request $ request , Controller $ controller = null ) { if ( $ this -> start === null ) return ; $ container = $ this -> container ; if ( ( $ response = include $ this -> start ) !== 1 ) return $ response ; }
Execute start file before controller .
7,692
protected function calculateDimensions ( $ originalWidth , $ originalHeight ) { if ( empty ( $ this -> targetWidth ) || ( $ this -> targetWidth <= 0 ) ) { throw new ImageProcessorException ( 'Target width is not set or is invalid' ) ; } if ( empty ( $ this -> targetHeight ) || ( $ this -> targetHeight <= 0 ) ) { throw ...
Calculate all required dimensions and offsets
7,693
public function getExpectedSize ( $ round = true ) { if ( empty ( $ this -> sourceFilename ) ) { throw new ImageProcessorException ( 'Source image is not set' ) ; } if ( empty ( $ this -> targetWidth ) || ( $ this -> targetWidth <= 0 ) ) { throw new ImageProcessorException ( 'Target width is not set or is invalid' ) ; ...
Get expected dimensions of processed image
7,694
public function getLocalization ( $ locale ) { $ localization = parent :: getLocalization ( $ locale ) ; if ( is_null ( $ localization ) ) { $ localization = $ this -> createLocalization ( $ locale ) ; } return $ localization ; }
Creates fake localization
7,695
public function persistLocalization ( GroupLocalization $ localization ) { if ( ! $ localization -> isPersistent ( ) ) { $ localization -> regenerateId ( ) ; $ this -> setLocalization ( $ localization ) ; $ localization -> setPersistent ( ) ; } }
Force localization persisting
7,696
public function findForProvider ( ) { $ qb = $ this -> createQueryBuilder ( 'm' ) ; $ qb -> select ( 'm.id, IDENTITY(m.parent) as parent, m.name, m.route, m.parameters, m.root, ' . 'm.attributes, m.options, t.title, t.path' ) -> leftJoin ( 'm.translations' , 't' , Expr \ Join :: WITH , $ qb -> expr ( ) -> eq ( 't.local...
Returns the menus data for the menu provider .
7,697
public function findSiblingContainer ( EM \ ContainerInterface $ container , $ next = false ) { if ( null === $ content = $ container -> getContent ( ) ) { return null ; } return $ this -> findSibling ( $ content -> getContainers ( ) , $ container , $ next ) ; }
Returns the sibling of the given container .
7,698
public function findSiblingRow ( EM \ RowInterface $ row , $ next = false ) { if ( null === $ container = $ row -> getContainer ( ) ) { return null ; } return $ this -> findSibling ( $ container -> getRows ( ) , $ row , $ next ) ; }
Returns the sibling of the given row .
7,699
public function findSiblingBlock ( EM \ BlockInterface $ block , $ next = false ) { if ( null === $ row = $ block -> getRow ( ) ) { return null ; } return $ this -> findSibling ( $ row -> getBlocks ( ) , $ block , $ next ) ; }
Returns the sibling of the given block .