idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
7,100
protected function formatTime ( \ Plop \ RecordInterface $ record , $ dateFormat = self :: DEFAULT_DATE_FORMAT ) { $ date = clone $ record [ 'createdDate' ] ; if ( $ this -> timezone !== null ) { $ date -> setTimeZone ( $ this -> timezone ) ; } return $ date -> format ( ( string ) $ dateFormat ) ; }
Format the creation date of a log record .
7,101
protected function formatException ( \ Exception $ exception ) { if ( ! $ this -> pythonLike ) { $ s = ( string ) $ exception ; if ( substr ( $ s , - 1 ) == "\n" ) { $ s = substr ( $ s , 0 , - 1 ) ; } return $ s ; } $ s = "Traceback (most recent call last):\n" ; $ traces = array ( ) ; foreach ( $ exception -> getTrace ...
Format an exception .
7,102
public static function fromLengths ( Length $ length , Length $ width , Length $ height ) { $ length = $ length -> convertTo ( UnitLength :: meters ( ) ) ; $ width = $ width -> convertTo ( UnitLength :: meters ( ) ) ; $ height = $ height -> convertTo ( UnitLength :: meters ( ) ) ; $ volume = $ length -> value ( ) * $ w...
Returns a volume measurement computed from the specified length width and height .
7,103
public function getAction ( ) { $ localization = $ this -> getPageLocalization ( ) ; $ pageRequest = $ this -> createPageRequest ( ) ; $ pageController = $ this -> getPageController ( ) ; $ templateException = $ response = $ internalHtml = null ; try { $ response = $ pageController -> execute ( $ pageRequest ) ; } catc...
Returns localization properties inner html and placeholder contents .
7,104
public function insertBlockAction ( ) { $ this -> isPostRequest ( ) ; $ this -> checkLock ( ) ; $ pageRequest = $ this -> createPageRequest ( ) ; $ blockComponentName = $ this -> getRequestParameter ( 'type' ) ; $ block = Block :: factory ( $ this -> getPageLocalization ( ) ) ; $ block -> setComponentName ( $ blockComp...
Handles new block insertion request .
7,105
public function deleteBlockAction ( ) { $ this -> isPostRequest ( ) ; $ this -> checkLock ( ) ; $ blockId = $ this -> getRequestParameter ( 'block_id' ) ; $ entityManager = $ this -> getEntityManager ( ) ; $ block = $ entityManager -> find ( Block :: CN ( ) , $ blockId ) ; if ( $ block === null ) { throw new CmsExcepti...
Handles block deletion request .
7,106
protected function removeHtmlTag ( Node $ body , $ lineno ) { if ( 0 === \ count ( $ body ) ) { $ body = new Node ( [ $ body ] , [ ] , $ lineno ) ; } $ this -> removeTagContent ( $ body , 0 , '/(|\ \\t|\\n|\\n\ \\t)<([a-zA-Z0-9]+)[a-zA-Z\=\'\"\ \/]+>(\\n?|\\r?)/' ) ; $ this -> removeTagContent ( $ body , \ count ( $ bo...
Removes tag .
7,107
protected function removeTagContent ( Node $ body , $ position , $ pattern ) : void { if ( $ body -> getNode ( $ position ) instanceof TextNode ) { $ positionBody = $ body -> getNode ( $ position ) -> getAttribute ( 'data' ) ; $ positionBody = preg_replace ( $ pattern , '' , $ positionBody ) ; $ body -> getNode ( $ pos...
Removes html tag defined by pattern .
7,108
function findControllerForView ( $ viewName ) { $ path = $ this -> viewService -> resolveTemplatePath ( $ viewName , $ base ) ; if ( isset ( $ this -> controllers [ $ path ] ) ) return $ this -> controllers [ $ path ] ; foreach ( $ this -> controllerNamespaces as $ nsPath => $ ns ) { if ( str_beginsWith ( $ path , $ ns...
Attempts to find a controller class for the given view template path .
7,109
public static function getEnumValues ( $ modelName , $ enumFieldName ) { $ schema = SolutionSchema :: getModelSchema ( $ modelName ) ; $ enum = $ schema -> getColumns ( ) [ $ enumFieldName ] ; return $ enum -> enumValues ; }
Finds the schema of the specified model and returns the values for the specified enum field
7,110
public function getErrors ( ) : array { $ errors = $ this -> validate ( ) -> getErrors ( ) ; foreach ( $ errors as & $ error ) { if ( is_string ( $ error ) && Translator :: isMessage ( $ error ) ) { $ error = $ this -> say ( $ error ) ; } unset ( $ error ) ; } return $ errors ; }
Get all validation messages .
7,111
private function setPermissions ( ) { if ( ! App :: environment ( 'production' ) || $ this -> option ( 'force' ) ) { $ this -> comment ( "Setting write permissions" ) ; foreach ( $ this -> writableDirectories as $ path ) { $ this -> process -> setCommandLine ( 'chmod -R 0777 ' . base_path ( $ path ) ) ; $ this -> proce...
Set permissions to writable directories if in non - production environment
7,112
protected function getContextID ( ) { $ result = ( int ) $ this -> request -> param ( 'Action' ) ; if ( $ result ) { return $ result ; } return ( int ) $ this -> request -> param ( 'ID' ) ; }
Get ID to query with in getContextObject
7,113
public function editAction ( Request $ request ) { $ block = $ this -> findBlockByRequest ( $ request ) ; try { $ response = $ this -> getEditor ( ) -> getBlockManager ( ) -> update ( $ block , $ request ) ; } catch ( EditorExceptionInterface $ e ) { return $ this -> handleException ( $ e ) ; } if ( $ response instance...
Edits the block .
7,114
public function layoutAction ( Request $ request ) { $ block = $ this -> findBlockByRequest ( $ request ) ; $ data = $ request -> request -> get ( 'data' , [ ] ) ; try { $ this -> getEditor ( ) -> getLayoutAdapter ( ) -> updateBlockLayout ( $ block , $ data ) ; } catch ( EditorExceptionInterface $ e ) { return $ this -...
Updates the block layout .
7,115
public function removeAction ( Request $ request ) { $ block = $ this -> findBlockByRequest ( $ request ) ; $ row = $ block -> getRow ( ) ; try { $ this -> getEditor ( ) -> getBlockManager ( ) -> delete ( $ block ) ; } catch ( EditorExceptionInterface $ e ) { return $ this -> handleException ( $ e ) ; } $ removedId = $...
Removes the block .
7,116
public function moveLeftAction ( Request $ request ) { $ block = $ this -> findBlockByRequest ( $ request ) ; try { $ sibling = $ this -> getEditor ( ) -> getBlockManager ( ) -> moveLeft ( $ block ) ; } catch ( EditorExceptionInterface $ e ) { return $ this -> handleException ( $ e ) ; } $ row = $ block -> getRow ( ) ;...
Moves the block left .
7,117
public function call ( Arguments $ values ) { ++ $ this -> called ; if ( $ this -> times > - 1 && $ this -> called > $ this -> times ) { throw new ExpectationException ( "Function {$this->name}({$this->arguments}) should be called {$this->times} times but called at least {$this->called} times" ) ; } $ matchers = $ this...
Call this function and get its return value .
7,118
public function GetMailsPage ( int $ lastKnownTicks = 0 , int $ pageSize = NULL ) { $ result = $ this -> ExecuteCall ( "GetMailsPage" , ( object ) [ "lastKnownTicks" => $ lastKnownTicks , "pageSize" => $ pageSize ] , GnResponseType :: ListGnMail ) ; return $ result ; }
Get the community - creator s mails .
7,119
public function SendMail ( string $ toLoginName , string $ mailBody ) { $ result = $ this -> ExecuteCall ( "SendMail" , ( object ) [ "toLoginName" => $ toLoginName , "mailBody" => $ mailBody ] , GnResponseType :: Json , FALSE , PHP_INT_MAX ) ; $ this -> ClearCacheForActionNames ( $ this :: CLEAR_CACHE_PATTERNS ) ; retu...
Send a message from the logged - in user - or the community - creator to the receiver .
7,120
final public function canAggregateWithRepository ( Repository $ repository , Collection $ collection ) { $ specificAggregate = $ repository -> getRepositorySpecificAggregate ( $ this ) ; if ( $ specificAggregate ) { return $ specificAggregate -> canCalculateByRepository ( $ repository , $ collection ) ; } return false ...
Checks if this aggregate can be calculated using it s repository
7,121
final public function aggregateWithRepository ( Repository $ repository , SqlStatement $ sqlStatement , Collection $ collection , & $ namedParams ) { $ specificAggregate = $ repository -> getRepositorySpecificAggregate ( $ this ) ; if ( $ specificAggregate ) { $ specificAggregate -> calculateByRepository ( $ repository...
Attempts to get the repository to do the aggregation .
7,122
public function getNumber ( $ min , $ max ) { $ min = ( int ) $ min ; $ max = ( int ) $ max ; if ( $ min > $ max ) { throw new \ InvalidArgumentException ( 'Invalid minimum and maximum value' ) ; } if ( $ min === $ max ) { return $ min ; } $ difference = $ max - $ min ; if ( ! is_int ( $ difference ) ) { throw new Gene...
Returns a random integer between given minimum and maximum .
7,123
private function getByteNumber ( $ limit ) { $ bits = 1 ; $ mask = 1 ; while ( $ limit >> $ bits > 0 ) { $ mask |= 1 << $ bits ; $ bits ++ ; } $ bytes = ( int ) ceil ( $ bits / 8 ) ; do { $ result = $ this -> readByteNumber ( $ bytes ) & $ mask ; } while ( $ result > $ limit ) ; return $ result ; }
Returns a random number generated using the random byte generator .
7,124
private function readByteNumber ( $ bytes ) { $ values = unpack ( self :: $ byteFormats [ $ bytes - 1 ] , $ this -> byteGenerator -> getBytes ( $ bytes ) ) + self :: $ byteDefaults ; return $ values [ 'a' ] | $ values [ 'b' ] << 16 | $ values [ 'c' ] << 32 | $ values [ 'd' ] << 48 ; }
Returns a number from byte generator based on given number of bytes .
7,125
public function update ( Model \ BlockInterface $ block , Request $ request ) { return $ this -> editor -> getBlockPlugin ( $ block -> getType ( ) ) -> update ( $ block , $ request ) ; }
Updates the block .
7,126
public function delete ( Model \ BlockInterface $ block ) { if ( $ block -> isAlone ( ) || $ block -> isNamed ( ) ) { throw new InvalidOperationException ( "The block can't be removed because it is named or the parent row does not have enough children." ) ; } if ( null === $ row = $ block -> getRow ( ) ) { throw new In...
Deletes the block .
7,127
public function moveDown ( Model \ BlockInterface $ block ) { $ row = $ block -> getRow ( ) ; if ( null === $ row || $ row -> isLast ( ) ) { throw new InvalidOperationException ( "This block can't be moved to the top." ) ; } $ sibling = $ this -> editor -> getRepository ( ) -> findSiblingRow ( $ row , true ) ; if ( nul...
Moves the block down .
7,128
public function moveLeft ( Model \ BlockInterface $ block ) { $ sibling = $ this -> editor -> getRepository ( ) -> findSiblingBlock ( $ block , false ) ; if ( null === $ sibling ) { throw new InvalidOperationException ( "The block can't be moved to the right as no sibling block has been found." ) ; } $ block -> setPosi...
Moves the block to the left .
7,129
public function moveRight ( Model \ BlockInterface $ block ) { $ sibling = $ this -> editor -> getRepository ( ) -> findSiblingBlock ( $ block , true ) ; if ( null === $ sibling ) { throw new InvalidOperationException ( "The block can't be moved to the right as no sibling block has been found." ) ; } $ block -> setPosi...
Moves the block to the right .
7,130
public function append ( $ placeHolder ) { if ( ! $ placeHolder instanceof PlaceHolder ) { throw new \ LogicException ( __METHOD__ . " accepts PlaceHolder arguments only" ) ; } if ( isset ( $ this -> localization ) ) { $ placeHolderName = $ placeHolder -> getName ( ) ; if ( $ placeHolder -> getLocked ( ) || $ placeHold...
Use only append to fill this object must start with top elements
7,131
public function getLastByName ( $ name ) { $ placeHolder = null ; foreach ( $ this as $ placeHolderTest ) { if ( $ placeHolderTest -> getName ( ) == $ name ) { $ placeHolder = $ placeHolderTest ; } } return $ placeHolder ; }
Loads the last place holder in the set by the name provided
7,132
public static function fetch ( $ attributeId , $ version , $ asObject = true ) { $ list = eZPersistentObject :: fetchObjectList ( self :: definition ( ) , null , array ( 'contentobject_attribute_id' => $ attributeId , 'contentobject_version' => $ version ) , null , null , $ asObject ) ; if ( isset ( $ list [ 0 ] ) ) re...
Fetch map location by attribute id and version
7,133
static function removeById ( $ attributeId , $ version = null ) { if ( $ version !== null ) $ conds = array ( 'contentobject_attribute_id' => $ attributeId , 'contentobject_version' => $ version ) ; else $ conds = array ( 'contentobject_attribute_id' => $ attributeId ) ; eZPersistentObject :: removeObject ( self :: def...
Remove a eZGmapLocation object form database .
7,134
private function createNestedSetNode ( LifecycleEventArgs $ args ) { $ entity = $ args -> getEntity ( ) ; if ( $ entity instanceof EntityNodeInterface ) { $ em = $ args -> getEntityManager ( ) ; $ entityName = $ entity -> getNestedSetRepositoryClassName ( ) ; $ repository = $ em -> getRepository ( $ entityName ) ; $ do...
Creates the Doctrine nested set node
7,135
public function doUninstall ( ) : void { $ this -> uninstallDB ( ) ; $ this -> uninstallFiles ( ) ; ModuleManager :: unRegisterModule ( $ this -> MODULE_ID ) ; }
Revert module installation
7,136
public function installFiles ( ) : void { if ( ! $ this -> isDevelopmentMode ( ) ) { foreach ( $ this -> INSTALL_PATHS as $ path ) { $ files = $ this -> getRecursiveFiles ( $ path ) ; foreach ( $ files as $ from => $ to ) { $ dir = dirname ( $ to ) ; if ( ! file_exists ( $ dir ) ) { if ( ! mkdir ( $ dir , BX_DIR_PERMIS...
Install module files
7,137
public function uninstallFiles ( ) : void { $ isDirEmpty = function ( $ dir ) { if ( ! file_exists ( $ dir ) || ! is_readable ( $ dir ) ) { return false ; } return count ( scandir ( $ dir , SCANDIR_SORT_NONE ) ) === 2 ; } ; if ( ! $ this -> isDevelopmentMode ( ) ) { foreach ( $ this -> INSTALL_PATHS as $ path ) { $ fil...
Remove files and symlinks created by module
7,138
protected function queryValues ( ) { foreach ( $ this -> defaultQueryParameters as $ parameter => $ validator ) { $ value = request ( $ parameter ) ; if ( $ value ) { $ this -> { $ parameter } = $ value ; } } return $ this ; }
Get query values .
7,139
protected function error ( $ errors = null , string $ message = '' ) { if ( ! $ errors ) { $ errors = [ 'Your request has not been validated by the system. Please check your request URL and parameters!' ] ; } else if ( ! is_array ( $ errors ) ) { $ errors = [ $ errors ] ; } return response ( ) -> json ( [ 'errors' => $...
Setup error response .
7,140
function createComponent ( $ class , Component $ parent , $ props = null , array $ bindings = null ) { $ component = $ this -> injector -> make ( $ class ) ; return $ component -> setup ( $ parent , $ this , $ props , $ bindings ) ; }
Creates an injectable component instance of the given class .
7,141
function createComponentFromTag ( $ tagName , Component $ parent , array $ props = null , array $ bindings = null , $ generic = false , $ strict = false ) { $ s = explode ( ':' , $ tagName , 2 ) ; if ( count ( $ s ) > 1 ) list ( $ prefix , $ tagName ) = $ s ; else $ prefix = '' ; if ( is_null ( $ props ) ) $ props = [ ...
Creates a component corresponding to the specified tag and optionally sets its published properties .
7,142
public function findOneById ( $ id ) { $ qb = $ this -> getQueryBuilder ( ) ; return $ qb -> leftJoin ( 'c.rows' , 'row' ) -> leftJoin ( 'row.blocks' , 'block' ) -> leftJoin ( 'block.translations' , 'translation' ) -> addSelect ( 'row' , 'block' , 'translation' ) -> andWhere ( $ qb -> expr ( ) -> eq ( 'c.id' , ':id' ) ...
Finds the container by id .
7,143
public function getCopyCount ( ContainerInterface $ container ) { $ query = $ this -> getEntityManager ( ) -> createQuery ( "SELECT COUNT(c.id) FROM {$this->getClassName()} c WHERE c.copy = :copied" ) ; return $ query -> setParameter ( 'copied' , $ container ) -> getSingleResult ( Query :: HYDRATE_SINGLE_SCALAR ) ; }
Returns the numbers of containers that copies the given one .
7,144
public function href ( $ routeName = '' , $ customAttributes = [ ] ) { if ( ! $ routeName ) { $ routeName = 'user.single' ; } $ getRoute = Route :: getRoutes ( ) -> getByName ( $ routeName ) ; if ( $ getRoute ) { $ routeParams = Route :: getRoutes ( ) -> getByName ( $ routeName ) -> parameterNames ( ) ; if ( $ this -> ...
Generate a custom URL to a user .
7,145
public function listAction ( ) { $ calendars = $ this -> getDoctrine ( ) -> getRepository ( 'CanalTPMttBundle:Calendar' ) -> findBy ( [ 'customer' => $ this -> getUser ( ) -> getCustomer ( ) ] , [ 'id' => 'desc' ] ) ; return $ this -> render ( 'CanalTPMttBundle:Calendar:list.html.twig' , [ 'no_left_menu' => true , 'cal...
Displays calendar list
7,146
public function exportAction ( ) { $ applicationCanonicalName = $ this -> get ( 'canal_tp_sam.application.finder' ) -> getCurrentApp ( ) -> getCanonicalName ( ) ; $ externalCoverageId = $ this -> getUser ( ) -> getCustomer ( ) -> getPerimeters ( ) -> first ( ) -> getExternalCoverageId ( ) ; $ calendars = $ this -> getD...
Export a zip with calendars
7,147
protected function doRun ( $ method , array $ args = [ ] ) { ob_start ( ) ; $ result = call_user_func_array ( $ method , array_merge ( [ $ this ] , $ args ) ) ; $ controllerBuffer = ob_get_clean ( ) ; if ( $ result !== null ) return $ result ; if ( $ controllerBuffer ) return $ controllerBuffer ; return null ; }
Run the action method .
7,148
function init ( ComponentPropertiesInterface $ o ) { foreach ( $ this -> props as $ p => $ i ) $ o -> $ p = $ i -> default ; return $ o ; }
Initializes the given instance of the target class to the default values set by metadata .
7,149
private function setMetadataFromDefaultValue ( ReflectionProperty $ prop , $ v ) { $ prop -> default = $ v ; if ( ! isset ( $ prop -> type ) ) switch ( gettype ( $ v ) ) { case 'string' : $ prop -> type = type :: string ; break ; case 'boolean' : $ prop -> type = type :: bool ; break ; case 'integer' : case 'double' : ...
Set the default value explicitly .
7,150
public function prepareAssets ( $ assets_directory , \ Smarty_Internal_Template $ smarty ) { if ( DS != '/' ) { $ assets_directory = str_replace ( '/' , DS , $ assets_directory ) ; } self :: $ assetsDirectory = $ assets_directory ; $ smartyParser = $ smarty -> smarty ; $ this -> prepareTemplateAssets ( $ smartyParser -...
Prepare current template assets
7,151
protected function prepareTemplateAssets ( TemplateDefinition $ templateDefinition , $ assets_directory , SmartyParser $ smartyParser ) { $ templateDirectories = $ smartyParser -> getTemplateDirectories ( $ templateDefinition -> getType ( ) ) ; $ templateDefinitionList = array_merge ( [ $ templateDefinition ] , $ templ...
Prepare template assets
7,152
public function computeAssetUrl ( $ assetType , $ params , \ Smarty_Internal_Template $ template , $ allowFilters = true ) { $ file = $ params [ 'file' ] ; if ( empty ( $ file ) ) { throw new \ InvalidArgumentException ( "The 'file' parameter is missing in an asset directive (type is '$assetType')" ) ; } $ assetOrigin ...
Retrieve asset URL
7,153
public function findSeasonByPerimeterAndDateTime ( Perimeter $ perimeter , \ DateTime $ dateTime ) { $ query = $ this -> getEntityManager ( ) -> createQueryBuilder ( ) -> select ( "s.id" ) -> from ( "CanalTPMttBundle:Season" , "s" ) -> where ( "s.published = TRUE" ) -> andWhere ( "s.perimeter = '" . $ perimeter -> getI...
used by webservice
7,154
public function findByPerimeter ( Perimeter $ perimeter ) { $ qb = $ this -> createQueryBuilder ( 's' ) ; $ qb -> where ( "s.perimeter = :perimeter" ) -> setParameter ( 'perimeter' , $ perimeter ) -> orderBy ( 's.startDate' , 'DESC' ) ; return $ qb -> getQuery ( ) -> getResult ( ) ; }
Find Seasons by perimeter and order by start date
7,155
public function onPagePublicUrl ( ResourceEventInterface $ event ) { $ resource = $ event -> getResource ( ) ; if ( ! $ resource instanceof PageInterface ) { return ; } $ event -> stopPropagation ( ) ; if ( ! $ resource -> isEnabled ( ) || $ resource -> isDynamicPath ( ) ) { return ; } $ event -> addData ( 'route' , $ ...
Page public url event handler .
7,156
private function createBreadcrumbRoot ( ) { if ( null === $ this -> breadcrumb ) { if ( null === $ home = $ this -> pageHelper -> getHomePage ( ) ) { throw new \ RuntimeException ( 'Home page not found.' ) ; } $ this -> breadcrumb = $ this -> factory -> createItem ( 'root' , [ 'childrenAttributes' => [ 'class' => 'brea...
Creates the breadcrumb root item .
7,157
public function reload ( ) { $ this -> propertyCache = [ ] ; $ repository = $ this -> getRepository ( ) ; $ repository -> reHydrateObject ( $ this , $ this -> uniqueIdentifier ) ; }
Requests that the model data be re - fetched from the repository
7,158
protected function performAfterSave ( callable $ callback , $ key = null ) { if ( $ key ) { $ this -> callbacksToRunAfterSave [ $ key ] = $ callback ; } else { $ this -> callbacksToRunAfterSave [ ] = $ callback ; } }
Allows a callback function to be run when the model is saved .
7,159
final public function getRepository ( ) { $ repositories = & Application :: current ( ) -> getSharedArray ( "ModelRepositories" ) ; if ( ! isset ( $ repositories [ $ this -> modelName ] ) ) { $ repositories [ $ this -> modelName ] = $ this -> createRepository ( ) ; } return $ repositories [ $ this -> modelName ] ; }
Returns the cached repository and generates one if it doesn t exist .
7,160
public static function clearObjectCache ( ) { $ object = SolutionSchema :: getModel ( get_called_class ( ) ) ; $ repository = $ object -> getRepository ( ) ; $ repository -> clearObjectCache ( ) ; }
Removes the cache of objects from the repository representing this model type .
7,161
public static function findFirst ( Filter ... $ filters ) { $ results = static :: find ( ... $ filters ) ; if ( sizeof ( $ results ) == 0 ) { throw new RecordNotFoundException ( get_called_class ( ) , 0 ) ; } return $ results [ 0 ] ; }
Finds the first model matching the given filters .
7,162
public static function findLast ( Filter ... $ filters ) { $ results = static :: find ( ... $ filters ) ; $ modelClass = get_called_class ( ) ; $ model = new $ modelClass ( ) ; $ results -> addSort ( $ model -> getUniqueIdentifierColumnName ( ) , false ) ; if ( sizeof ( $ results ) == 0 ) { throw new RecordNotFoundExce...
Finds the last model matching the given filters .
7,163
public static function find ( Filter ... $ filters ) { $ modelClass = get_called_class ( ) ; $ collection = new RepositoryCollection ( $ modelClass ) ; $ collection -> filter ( ... $ filters ) ; return $ collection ; }
Returns the Collection of models matching the given filter .
7,164
final public function save ( $ forceSaveRegardlessOfState = false ) { try { $ this -> isConsistent ( ) ; } catch ( ModelConsistencyValidationException $ er ) { throw $ er ; } if ( ! $ forceSaveRegardlessOfState && ! $ this -> isNewRecord ( ) && ! $ this -> hasChanged ( ) ) { return $ this -> uniqueIdentifier ; } $ this...
Persists the model data associated with this data object with the relevant repository .
7,165
public function setUniqueIdentifier ( $ value ) { $ this -> newRecord = $ value === null ; $ this -> uniqueIdentifier = $ value ; $ this [ $ this -> uniqueIdentifierColumnName ] = $ value ; }
Set s the unique identifier for this object .
7,166
private function getColumnSchemaForColumnReference ( $ columnReference , $ fromModelSchema ) { if ( strpos ( $ columnReference , "." ) !== false ) { $ parts = explode ( "." , $ columnReference ) ; $ relationshipName = $ parts [ 0 ] ; $ this -> ensureRelationshipsArePopulated ( ) ; $ relationships = & Application :: cur...
Returns the schema Column object for the matching column reference .
7,167
final public function isConsistent ( $ throwException = true ) { $ errors = $ this -> getConsistencyValidationErrors ( ) ; if ( sizeof ( $ errors ) == 0 ) { return true ; } if ( $ throwException ) { throw new ModelConsistencyValidationException ( $ errors ) ; } return false ; }
Returns true of the data in the model is consistent with the entity we are trying to model .
7,168
protected function loadFromUniqueIdentifier ( $ uniqueIdentifier ) { $ this -> newRecord = false ; $ repository = $ this -> getRepository ( ) ; $ repository -> hydrateObject ( $ this , $ uniqueIdentifier ) ; $ this -> onLoaded ( ) ; }
Loads a record using the unique identifier .
7,169
public function get ( $ key , $ age = false ) { $ file = $ this -> filename ( $ key ) ; if ( is_file ( $ file ) ) { if ( $ age ) { $ age = filemtime ( $ file ) + $ this -> config [ 'age' ] > time ( ) ; } if ( ! $ age ) { return unserialize ( file_get_contents ( $ file ) ) ; } return false ; } return null ; }
Get an item from the cache if available .
7,170
public function put ( $ key , $ item ) { $ file = $ this -> filename ( $ key ) ; if ( ! file_put_contents ( $ file , serialize ( $ item ) ) ) { throw new \ Exception ( t ( "Failed writing cache object '!key'." , [ '!key' => $ key ] ) ) ; } }
Put an item to the cache .
7,171
public function pruneAll ( ) { $ files = glob ( $ this -> config [ 'basepath' ] . '/*' ) ; $ items = count ( $ files ) ; array_map ( 'unlink' , $ files ) ; return $ items ; }
Prune all items from cache .
7,172
function getViewModel ( ) { if ( isset ( $ this -> shadowViewModel ) ) return $ this -> shadowViewModel ; $ shadowDOM = $ this -> getShadowDOM ( ) ; return $ shadowDOM ? $ shadowDOM -> getDataBinder ( ) -> getViewModel ( ) : null ; }
Returns the component s view model .
7,173
protected function afterPreRun ( ) { parent :: afterPreRun ( ) ; $ vm = $ this -> getViewModel ( ) ; if ( $ vm ) { $ this -> baseViewModel ( $ vm ) ; $ this -> viewModel ( $ vm ) ; $ vm -> init ( ) ; } }
Extension hook .
7,174
protected function baseViewModel ( ViewModelInterface $ viewModel ) { $ props = $ this -> props ? $ this -> props -> getAll ( ) : null ; if ( $ props ) $ viewModel [ 'props' ] = $ props ; }
Override to set data on the component s view model that will be set for component subclasses .
7,175
public function getConfigurationOverrides ( ) { if ( $ this -> overrides ) { return $ this -> overrides ; } return $ this -> overrides = $ this -> container [ 'config.universal_loader' ] -> load ( $ this -> getSupraRoot ( ) . '/config.yml' ) ; }
Basically parses main supra config
7,176
public function addConfigurationSection ( SupraPackageInterface $ package , $ data ) { $ overrides = $ this -> getConfigurationOverrides ( ) ; if ( isset ( $ overrides [ $ package -> getName ( ) ] ) ) { $ processor = new Processor ( ) ; $ data = $ processor -> processConfiguration ( $ package -> getConfiguration ( ) , ...
Adds configuration section for later processing
7,177
public function getConfigurationSection ( $ package ) { if ( ! isset ( $ this -> configurationSections [ $ package ] ) ) { throw new \ Exception ( sprintf ( 'There is no configuration section for package "%s"' , $ package ) ) ; } return $ this -> configurationSections [ $ package ] [ 'data' ] ; }
Gets configuration section data by package name if defined
7,178
public function resolveName ( $ package ) { if ( is_object ( $ package ) ) { $ package = get_class ( $ package ) ; } $ package = substr ( $ package , strrpos ( $ package , '\\' ) ) ; $ package = trim ( $ package , '\\' ) ; $ package = str_replace ( array ( 'Supra' , 'Package' ) , '' , $ package ) ; return $ package ; }
This function uses woodo magic to extract short package name from className
7,179
protected function buildDirectories ( ) { $ reflection = new \ ReflectionClass ( $ this ) ; $ this -> container -> setParameter ( 'directories.supra_root' , dirname ( $ reflection -> getFileName ( ) ) ) ; $ this -> container -> setParameter ( 'directories.project_root' , dirname ( $ this -> container -> getParameter ( ...
Sets up package directories contents
7,180
protected function finish ( ContainerInterface $ container ) { foreach ( $ this -> getPackages ( ) as $ package ) { $ package -> finish ( $ container ) ; } }
Allows packages to do some changes after the configuration has been built
7,181
protected function injectPackages ( ContainerInterface $ container ) { foreach ( $ this -> getPackages ( ) as $ package ) { $ package -> inject ( $ container ) ; } }
Injects packages into a container
7,182
public function addLayout ( $ media , ThemeLayoutInterface $ layout ) { $ templateLayout = new TemplateLayout ( $ media ) ; $ templateLayout -> setLayoutName ( $ layout -> getName ( ) ) ; $ templateLayout -> setTemplate ( $ this ) ; return $ templateLayout ; }
Add layout for specific media .
7,183
public function hasLayout ( $ media = TemplateLayout :: MEDIA_SCREEN ) { $ has = $ this -> templateLayouts -> offsetExists ( $ media ) ; return $ has ; }
Whether the layout exists
7,184
public function getLayoutName ( $ media = TemplateLayout :: MEDIA_SCREEN ) { $ templateLayouts = $ this -> getTemplateLayouts ( ) ; if ( $ templateLayouts -> offsetExists ( $ media ) ) { $ templateLayout = $ templateLayouts -> offsetGet ( $ media ) ; return $ templateLayout -> getLayoutName ( ) ; } throw new \ RuntimeE...
Get layout name for specified media type .
7,185
public function addJsRequirement ( $ js , LambdaHelper $ helper = null ) { $ js = trim ( $ js ) ; $ key = md5 ( $ js ) ; if ( ! isset ( self :: $ jsRequirements [ $ key ] ) ) { if ( $ helper !== null ) { $ js = $ helper -> render ( $ js ) ; } self :: $ jsRequirements [ $ key ] = $ js ; } }
Enqueue an external JavaScript file .
7,186
public function addCssRequirement ( $ css , LambdaHelper $ helper = null ) { $ css = trim ( $ css ) ; $ key = md5 ( $ css ) ; if ( ! isset ( self :: $ cssRequirements [ $ key ] ) ) { if ( $ helper !== null ) { $ css = $ helper -> render ( $ css ) ; } self :: $ cssRequirements [ $ key ] = $ css ; } }
Enqueue an external CSS file .
7,187
public function render ( array $ parameters = array ( ) ) { if ( $ this -> templateName === null ) { throw new \ RuntimeException ( 'Template name was not specified, nothing to render.' ) ; } $ this -> output ( $ this -> templating -> render ( $ this -> templateName , array_merge ( $ this -> parameters , $ parameters )...
Renders template and outputs it into response .
7,188
public function mapBackendRoutes ( ) { $ directory = __DIR__ . '/../../routes/backend' ; if ( is_dir ( $ directory ) ) { $ routeFiles = File :: files ( $ directory ) ; \ Route :: group ( [ 'middleware' => $ this -> middleware [ 'backend' ] , ] , function ( ) use ( $ routeFiles ) { foreach ( $ routeFiles as $ file ) { i...
Define Package Backend routes
7,189
public function mapFrontendRoutes ( ) { $ directory = base_path ( 'routes' ) ; if ( is_dir ( $ directory ) ) { $ routeFiles = File :: files ( $ directory ) ; $ excludeRoutes = [ 'base.php' , 'api.php' ] ; Route :: group ( [ 'middleware' => $ this -> middleware [ 'frontend' ] , ] , function ( ) use ( $ routeFiles , $ ex...
Define front end routes
7,190
public function mapFrontendBaseRoutes ( ) { $ projectConfig = Config :: get ( 'project' ) ; $ baseFile = base_path ( 'routes/base.php' ) ; \ Route :: group ( [ 'middleware' => $ this -> middleware [ 'frontend' ] , ] , function ( ) use ( $ baseFile ) { include $ baseFile ; } ) ; $ baseRoute = null ; foreach ( Route :: g...
Add Frontend base routes .
7,191
public function getRoutsFromTheme ( $ themeName ) { if ( Theme :: ifExists ( $ themeName ) ) { $ routeDir = base_path ( 'themes/' . $ themeName . '/routes' ) ; if ( is_dir ( $ routeDir ) ) { $ routeFiles = File :: files ( $ routeDir ) ; } } return $ this ; }
Get routes from a specific theme
7,192
public function mapPluginsBackendRoutes ( ) { foreach ( Plugin :: activePlugins ( ) as $ plugin ) { $ backendRoutes = $ plugin -> backendRoutes ( ) ; if ( $ backendRoutes ) { \ Route :: group ( [ 'middleware' => $ this -> middleware [ 'backend' ] , 'as' => 'Backend.' . $ plugin -> namespaceWithDot ( ) . "." , 'namespac...
Define Plugins backend routes for the application .
7,193
public function mapPluginsFrontendRoutes ( ) { foreach ( Plugin :: activePlugins ( ) as $ plugin ) { $ frontendRoutes = $ plugin -> frontendRoutes ( ) ; if ( $ frontendRoutes ) { \ Route :: group ( [ 'middleware' => $ this -> middleware [ 'frontend' ] , 'as' => $ plugin -> namespaceWithDot ( ) . "." , 'namespace' => $ ...
Define Plugins frontend routes for the application .
7,194
public function action ( $ action , $ parameters = [ ] , $ absolute = true ) { $ getProjectConfig = Config :: get ( 'project' ) ; if ( $ getProjectConfig [ 'multilanguage' ] && App :: getLocale ( ) != Language :: getDefault ( 'slug' ) ) { $ langParameter = array ( 'lang' => App :: getLocale ( ) ) ; } else { $ langParam...
Generate the URL to a controller action depending if url should contain language slug or not .
7,195
public function sortRoutes ( ) { $ originalRoutes = \ Route :: getRoutes ( ) ; $ routesByMethod = $ originalRoutes -> getRoutesByMethod ( ) ; \ Route :: setRoutes ( new RouteCollection ( ) ) ; $ sortedRoutes = [ ] ; foreach ( $ routesByMethod as $ method => $ methodRoutes ) { foreach ( $ methodRoutes as $ uri => $ rout...
Give hardcoded routes higher priority It goes through each route calculate their length and parameters and gives hardcoded routes higher priority than wild card routes
7,196
public function findByPhone ( Phone $ phone ) : Result { foreach ( $ this -> results as $ result ) { if ( $ result -> getPhone ( ) -> getValue ( ) === $ phone -> getValue ( ) ) { return $ result ; } } throw new ResultNotFoundException ( sprintf ( 'Not found result for phone "%s".' , $ phone ) ) ; }
Find the result by phone
7,197
public function getSuccessfullyResults ( ) : ResultCollection { $ successfullyResults = array_filter ( $ this -> results , function ( Result $ result ) { return $ result -> isSuccessfully ( ) ; } ) ; return new self ( ... $ successfullyResults ) ; }
Get successfully results
7,198
public function getFailedResults ( ) : ResultCollection { $ failedResults = array_filter ( $ this -> results , function ( Result $ result ) { return $ result -> isFailed ( ) ; } ) ; return new self ( ... $ failedResults ) ; }
Get failed results
7,199
public function url ( $ default = null ) { if ( $ this -> isIn ( $ this -> webDir ) ) $ src = $ this -> relativeToWebDir ( ) ; else $ src = $ default ; if ( $ this -> url && $ src ) return $ this -> url -> to ( $ src ) ; else return $ src ; }
Return the file url .