idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
7,800
protected function createForeignKey ( $ key ) { $ res = "\n\t\$table->addForeignKeyConstraint('" . $ key -> getForeignTableName ( ) . "', " . $ this -> outputPHP ( $ key -> getLocalColumns ( ) , 2 ) . ", " . $ this -> outputPHP ( $ key -> getForeignColumns ( ) , 2 ) . ", " . $ this -> outputPHP ( $ key -> getOptions ( ...
Build a foreign key .
7,801
public function productDataAccess ( $ params , & $ smarty ) { $ productId = $ this -> getRequest ( ) -> get ( 'product_id' ) ; if ( $ productId !== null ) { return $ this -> dataAccessWithI18n ( "Product" , $ params , ProductQuery :: create ( ) -> filterByPrimaryKey ( $ productId ) ) ; } return '' ; }
Provides access to an attribute of the current product
7,802
public function categoryDataAccess ( $ params , & $ smarty ) { $ categoryId = $ this -> getRequest ( ) -> get ( 'category_id' ) ; if ( $ categoryId === null ) { $ productId = $ this -> getRequest ( ) -> get ( 'product_id' ) ; if ( $ productId !== null ) { if ( null !== $ product = ProductQuery :: create ( ) -> findPk (...
Provides access to an attribute of the current category
7,803
public function contentDataAccess ( $ params , & $ smarty ) { $ contentId = $ this -> getRequest ( ) -> get ( 'content_id' ) ; if ( $ contentId !== null ) { return $ this -> dataAccessWithI18n ( "Content" , $ params , ContentQuery :: create ( ) -> filterByPrimaryKey ( $ contentId ) ) ; } return '' ; }
Provides access to an attribute of the current content
7,804
public function folderDataAccess ( $ params , & $ smarty ) { $ folderId = $ this -> getRequest ( ) -> get ( 'folder_id' ) ; if ( $ folderId === null ) { $ contentId = $ this -> getRequest ( ) -> get ( 'content_id' ) ; if ( $ contentId !== null ) { if ( null !== $ content = ContentQuery :: create ( ) -> findPk ( $ conte...
Provides access to an attribute of the current folder
7,805
public function brandDataAccess ( $ params , & $ smarty ) { $ brandId = $ this -> getRequest ( ) -> get ( 'brand_id' ) ; if ( $ brandId === null ) { $ productId = $ this -> getRequest ( ) -> get ( 'product_id' ) ; if ( $ productId !== null ) { if ( null !== $ product = ProductQuery :: create ( ) -> findPk ( $ productId...
Provides access to an attribute of the current brand
7,806
public function currencyDataAccess ( $ params , $ smarty ) { $ currency = $ this -> getSession ( ) -> getCurrency ( ) ; if ( $ currency ) { return $ this -> dataAccessWithI18n ( "Currency" , $ params , CurrencyQuery :: create ( ) -> filterByPrimaryKey ( $ currency -> getId ( ) ) , array ( "NAME" ) ) ; } return '' ; }
Provides access to an attribute of the current currency
7,807
public function countryDataAccess ( $ params , $ smarty ) { switch ( $ params [ "ask" ] ) { case "default" : return $ this -> dataAccessWithI18n ( "defaultCountry" , $ params , CountryQuery :: create ( ) -> filterByByDefault ( 1 ) -> limit ( 1 ) ) ; } return '' ; }
Provides access to an attribute of the default country
7,808
public function cartDataAccess ( $ params , $ smarty ) { if ( array_key_exists ( 'currentCountry' , self :: $ dataAccessCache ) ) { $ taxCountry = self :: $ dataAccessCache [ 'currentCountry' ] ; } else { $ taxCountry = $ this -> taxEngine -> getDeliveryCountry ( ) ; self :: $ dataAccessCache [ 'currentCountry' ] = $ t...
Provides access to an attribute of the cart
7,809
public function orderDataAccess ( $ params , & $ smarty ) { $ order = $ this -> getSession ( ) -> getOrder ( ) ; $ attribute = $ this -> getNormalizedParam ( $ params , array ( 'attribute' , 'attrib' , 'attr' ) ) ; switch ( $ attribute ) { case 'untaxed_postage' : return $ order -> getUntaxedPostage ( ) ; case 'postage...
Provides access to an attribute of the current order
7,810
public function moduleConfigDataAccess ( $ params , $ smarty ) { $ key = $ this -> getParam ( $ params , 'key' , false ) ; $ moduleCode = $ this -> getParam ( $ params , 'module' , false ) ; $ locale = $ this -> getParam ( $ params , 'locale' ) ; if ( null === $ locale ) { $ locale = $ this -> getSession ( ) -> getLang...
Provides access to a module configuration value
7,811
public function metaAccess ( $ params , $ smarty ) { $ meta = $ this -> getParam ( $ params , 'meta' , null ) ; $ key = $ this -> getParam ( $ params , 'key' , null ) ; $ id = $ this -> getParam ( $ params , 'id' , null ) ; $ cacheKey = sprintf ( 'meta_%s_%s_%s' , $ meta , $ key , $ id ) ; $ out = null ; if ( array_key...
Retrieve meta data associated to an element
7,812
private function underscoreToCamelcase ( $ str ) { $ words = explode ( '_' , strtolower ( $ str ) ) ; $ return = '' ; foreach ( $ words as $ word ) { $ return .= ucfirst ( trim ( $ word ) ) ; } return $ return ; }
Transcode an underscored string into a camel - cased string eg . default_folder into DefaultFolder
7,813
public function redirectTo ( $ route = null ) { if ( is_null ( $ route ) ) { $ url = $ this -> di -> request -> getCurrentUrl ( ) ; } else { $ url = $ this -> di -> url -> create ( $ route ) ; } $ this -> di -> response -> redirect ( $ url ) ; }
Redirect to current or another route .
7,814
private function verify ( RequestInterface $ httpRequest ) { $ extensions = array ( 'crt' , 'pem' , 'cer' , 'der' ) ; $ caDir = __DIR__ . '/../CA/' ; $ url = $ httpRequest -> getUrl ( ) ; if ( substr ( $ url , 0 , 5 ) != 'https' ) { $ httpRequest -> getConfig ( ) -> set ( 'verify' , false ) ; return ; } $ httpRequest -...
Looks for a Certificate Authority file in the CA folder that matches the host and update the verify option to its full path . If no specific file regarding a host is found uses curl - ca - bundle . crt by default .
7,815
private function executeHttpRequest ( RequestInterface $ httpRequest ) { if ( $ this -> authenticationMethod ) { $ this -> authenticationMethod -> authorizeRequest ( $ this , $ httpRequest ) ; } $ httpResponse = $ this -> client -> send ( $ httpRequest ) ; if ( $ httpResponse -> getStatusCode ( ) == 401 && $ this -> au...
Sends the HTTP request .
7,816
public function addProvider ( ProviderInterface $ provider ) { if ( array_key_exists ( $ name = $ provider -> getName ( ) , $ this -> providers ) ) { throw new \ InvalidArgumentException ( "Wide search provider '{$name}' is already registered." ) ; } $ this -> providers [ $ name ] = $ provider ; }
Adds the provider .
7,817
public function search ( $ expression ) { $ results = [ ] ; foreach ( $ this -> providers as $ provider ) { $ results = array_merge ( $ results , $ provider -> search ( $ expression ) ) ; } usort ( $ results , function ( Result $ a , Result $ b ) { if ( $ a -> getScore ( ) == $ b -> getScore ( ) ) { return 0 ; } return...
Performs a wide site search .
7,818
public function apply ( ) { $ fonts = $ this -> getOnFonts ( $ this -> config -> getArrayCopy ( ) ) ; $ url = $ this -> fontsUrl ( $ fonts ) ; $ this -> enqueue ( $ url ) ; }
Apply Google Font customizations .
7,819
protected function fontsUrl ( $ fonts ) : string { $ font_families = \ array_keys ( $ fonts ) ; $ query_args = [ 'family' => \ rawurlencode ( \ implode ( '|' , $ font_families ) ) , 'subset' => \ rawurlencode ( 'latin,latin-ext' ) , ] ; return \ add_query_arg ( $ query_args , 'https://fonts.googleapis.com/css' ) ; }
Build the fonts URL .
7,820
public function setContext ( $ context = 'development' ) { switch ( $ context ) { case 'production' : break ; case 'development' : error_reporting ( - 1 ) ; ini_set ( 'display_errors' , 1 ) ; ini_set ( 'output_buffering' , 0 ) ; set_exception_handler ( function ( $ exception ) { echo "Anax: Uncaught exception: <p>" . $...
Init the logger depending on its context production development or debug .
7,821
public function getBlockManager ( ) { if ( null === $ this -> blockManager ) { $ this -> blockManager = new Manager \ BlockManager ( $ this -> config [ 'default_block_plugin' ] ) ; $ this -> blockManager -> setEditor ( $ this ) ; } return $ this -> blockManager ; }
Returns the block manager .
7,822
public function getRowManager ( ) { if ( null === $ this -> rowManager ) { $ this -> rowManager = new Manager \ RowManager ( ) ; $ this -> rowManager -> setEditor ( $ this ) ; } return $ this -> rowManager ; }
Returns the row manager .
7,823
public function getContainerManager ( ) { if ( null === $ this -> containerManager ) { $ this -> containerManager = new Manager \ ContainerManager ( $ this -> config [ 'default_container_plugin' ] ) ; $ this -> containerManager -> setEditor ( $ this ) ; } return $ this -> containerManager ; }
Returns the container manager .
7,824
public function getContentManager ( ) { if ( null === $ this -> contentManager ) { $ this -> contentManager = new Manager \ ContentManager ( ) ; $ this -> contentManager -> setEditor ( $ this ) ; } return $ this -> contentManager ; }
Returns the content manager .
7,825
public function getLayoutAdapter ( ) { if ( null === $ this -> layoutAdapter ) { $ class = $ this -> config [ 'layout' ] [ 'adapter' ] ; $ this -> layoutAdapter = new $ class ; $ this -> layoutAdapter -> setEditor ( $ this ) ; } return $ this -> layoutAdapter ; }
Returns the layout adapter .
7,826
public function getViewBuilder ( ) { if ( null === $ this -> viewBuilder ) { $ this -> viewBuilder = new View \ ViewBuilder ( ) ; $ this -> viewBuilder -> setEditor ( $ this ) ; } return $ this -> viewBuilder ; }
Returns the view builder .
7,827
public function getContentData ( ) { $ data = [ 'locale' => $ this -> contentLocaleProvider -> getCurrentLocale ( ) , ] ; if ( null !== $ page = $ this -> pageHelper -> getCurrent ( ) ) { $ data [ 'id' ] = $ page -> getId ( ) ; } return $ data ; }
Returns the content locale .
7,828
public function createDefaultContainer ( $ type = null , array $ data = [ ] , EM \ ContentInterface $ content = null ) { return $ this -> getContainerManager ( ) -> create ( $ content , $ type , $ data ) ; }
Creates a default container .
7,829
public function createDefaultRow ( array $ data = [ ] , EM \ ContainerInterface $ container = null ) { return $ this -> getRowManager ( ) -> create ( $ container , $ data ) ; }
Creates a default row .
7,830
public function createDefaultBlock ( $ type = null , array $ data = [ ] , EM \ RowInterface $ row = null ) { return $ this -> getBlockManager ( ) -> create ( $ row , $ type , $ data ) ; }
Creates a default block .
7,831
public function getPluginsConfig ( ) { $ config = [ 'block' => [ ] , 'container' => [ ] , ] ; foreach ( $ this -> pluginRegistry -> getBlockPlugins ( ) as $ plugin ) { $ config [ 'block' ] [ ] = [ 'name' => $ plugin -> getName ( ) , 'title' => $ plugin -> getTitle ( ) , 'path' => $ plugin -> getJavascriptFilePath ( ) ,...
Returns the plugins configuration .
7,832
public function getDefinition ( ) { $ columnNames = " (`" . implode ( "`,`" , $ this -> columnNames ) . "`)" ; switch ( $ this -> indexType ) { case self :: PRIMARY : return "PRIMARY KEY" . $ columnNames ; break ; case self :: INDEX : return "KEY `" . $ this -> indexName . "`" . $ columnNames ; break ; case self :: UNI...
Returns the definition for this index .
7,833
public function getHomePage ( ) : ? PageInterface { if ( false === $ this -> homePage ) { $ this -> homePage = $ this -> findByRoute ( $ this -> homeRoute ) ; } return $ this -> homePage ; }
Returns the home page .
7,834
private function getCmsRoutes ( ) : array { if ( $ this -> routes ) { return $ this -> routes ; } $ item = $ this -> cache -> getItem ( self :: PAGES_ROUTES_CACHE_KEY ) ; if ( $ item -> isHit ( ) ) { return $ this -> routes = $ item -> get ( ) ; } $ routes = $ this -> repository -> getPagesRoutes ( ) ; $ item -> set ( ...
Returns the cms routes list .
7,835
public static function getGlobalSessionId ( ) { if ( isset ( $ _SERVER [ 'PHPSESSID' ] ) ) return $ _SERVER [ 'PHPSESSID' ] ; elseif ( isset ( $ _POST [ 'PHPSESSID' ] ) ) return $ _POST [ 'PHPSESSID' ] ; elseif ( isset ( $ _GET [ 'PHPSESSID' ] ) ) return $ _GET [ 'PHPSESSID' ] ; }
Return the global session id .
7,836
public function get ( $ path , $ default = null ) { if ( ! $ this -> has ( $ path ) ) return $ default ; return ArrayUtils :: get ( $ _SESSION , $ path ) ; }
Get a session variable .
7,837
public function set ( $ path , $ value = null ) { if ( is_array ( $ path ) ) { foreach ( $ path as $ k => $ v ) static :: set ( $ k , $ v ) ; } else ArrayUtils :: set ( $ _SESSION , $ path , $ value ) ; }
Set a session variable .
7,838
protected function createImageSize ( ImageReferencedElement $ entity , EntityManager $ em ) { $ imageId = $ entity -> getImageId ( ) ; $ fileStorage = $ this -> container [ 'cms.file_storage' ] ; $ image = $ fileStorage -> findImage ( $ imageId ) ; if ( $ image === null ) { $ this -> container -> getLogger ( ) -> warn ...
Internal method to create the size
7,839
public function add ( $ field , $ relation , $ value ) { $ this -> conditions [ ] = array ( self :: FIELD_POS => $ field , self :: RELATION_POS => $ relation , self :: VALUE_POS => $ value ) ; }
Add a condition to the collection
7,840
private function buildImageOptionsForm ( FormBuilderInterface $ builder , array $ options ) { $ builder -> add ( 'align' , Type \ ChoiceType :: class , [ 'label' => 'ekyna_cms.block.field.align' , 'choices' => [ 'Left' => 'left' , 'Center' => 'center' , 'Right' => 'right' , ] , 'required' => true , 'select2' => false ,...
Builds the image options form .
7,841
public static function email ( string $ value ) : bool { $ result = filter_var ( $ value , FILTER_VALIDATE_EMAIL ) ; return is_string ( $ result ) && $ value === $ result ; }
Is email .
7,842
public static function url ( string $ value ) : bool { $ result = filter_var ( $ value , FILTER_VALIDATE_URL ) ; return is_string ( $ result ) && $ value === $ result ; }
Is url .
7,843
public static function ip ( string $ value ) : bool { $ result = filter_var ( $ value , FILTER_VALIDATE_IP ) ; return is_string ( $ result ) && $ value === $ result ; }
Is ip .
7,844
public static function macAddress ( string $ value ) : bool { $ result = filter_var ( $ value , FILTER_VALIDATE_MAC ) ; return is_string ( $ result ) && $ value === $ result ; }
Is mac - address .
7,845
public function filter ( $ value , SolrDisMaxQuery $ query = null , Facets $ facets = null ) { if ( null === $ query ) { throw new DomainException ( '$query must not be null' ) ; } if ( null === $ facets ) { throw new DomainException ( '$facets must not be null' ) ; } $ this -> createQuery ( $ value , $ query , $ facet...
Filter query based on given value
7,846
protected function handle ( \ Plop \ RecordInterface $ record ) { if ( $ this -> filters -> filter ( $ record ) ) { $ this -> callHandlers ( $ record ) ; } return $ this ; }
Handle a log record .
7,847
protected function callHandlers ( \ Plop \ RecordInterface $ record ) { if ( ! count ( $ this -> handlers ) && ! $ this -> emittedWarning ) { $ stderr = $ this -> getStderr ( ) ; fprintf ( $ stderr , 'No handlers could be found for logger ("%s" in "%s")' . "\n" , $ this -> cls . ( $ this -> cls === null || $ this -> cl...
Call every handler associated with this logger in turn passing them a log record to handle .
7,848
public function showlist ( ) { if ( $ this -> getRecord ( ) && $ this -> getRecord ( ) instanceof ItemList ) { if ( $ this -> request -> getExtension ( ) == 'csv' ) { $ this -> response -> addHeader ( 'Content-type' , 'text/csv' ) ; return $ this -> getRecord ( ) -> toCSV ( ) ; } else { $ content = $ this -> getRecord ...
Shows a specific item list
7,849
public function getContainer ( ) { if ( ! $ this -> container ) { $ this -> container = $ this -> buildContainer ( ) ; $ this -> container [ 'kernel' ] = $ this ; } return $ this -> container ; }
Get the services container .
7,850
public function getConfig ( ) { if ( ! $ this -> config ) { $ this -> config = $ config = new \ Asgard \ Config \ Config ( $ this -> getCache ( ) ) ; if ( file_exists ( $ this -> params [ 'root' ] . '/config' ) ) $ config -> loadDir ( $ this -> params [ 'root' ] . '/config' , $ this -> getEnv ( ) ) ; } return $ this ->...
Get the config dependency .
7,851
public function setup ( ) { $ this -> errorHandler = $ errorHandler = \ Asgard \ Debug \ ErrorHandler :: register ( ) ; if ( php_sapi_name ( ) !== 'cli' ) \ Asgard \ Debug \ Debug :: setFormat ( 'html' ) ; register_shutdown_function ( [ $ this , 'shutdownFunction' ] ) ; $ this -> addShutdownCallback ( [ $ errorHandler ...
Setup errorhandler shutdown and load compiled classes .
7,852
public function loadBundles ( ) { if ( $ this -> loaded ) return ; $ this -> bundles = $ this -> doGetBundles ( ) ; $ container = $ this -> getContainer ( ) ; if ( $ this -> params [ 'env' ] ) { if ( file_exists ( $ this -> params [ 'root' ] . '/app/bootstrap_' . strtolower ( $ this -> params [ 'env' ] ) . '.php' ) ) i...
Load the bundles .
7,853
protected function setDefaultEnvironment ( ) { if ( isset ( $ this -> params [ 'env' ] ) ) return ; if ( defined ( '_ENV_' ) ) $ this -> params [ 'env' ] = _ENV_ ; elseif ( file_exists ( $ file = $ this -> params [ 'root' ] . '/storage/environment' ) ) $ this -> params [ 'env' ] = trim ( file_get_contents ( $ file ) ) ...
Set the default environment .
7,854
protected function buildContainer ( ) { $ cache = $ this -> getCache ( ) ; if ( $ cache ) { if ( ( $ container = $ cache -> fetch ( 'asgard.container' ) ) instanceof \ Asgard \ Container \ Container ) { $ container [ 'kernel' ] = $ this ; $ container [ 'errorHandler' ] = $ this -> errorHandler ; $ this -> container = $...
Register the bundle s services .
7,855
protected function runBundles ( ) { $ bundles = $ this -> getAllBundles ( ) ; foreach ( $ bundles as $ bundle ) $ bundle -> run ( $ this -> container ) ; }
Run the bundles .
7,856
public function getAllBundles ( ) { if ( $ this -> bundles === null ) $ this -> bundles = $ this -> doGetBundles ( ) ; return $ this -> bundles ; }
Get all the bundles .
7,857
public function getHooksAnnotationReader ( ) { $ AnnotationReader = new \ Asgard \ Hook \ AnnotationReader ; if ( $ this -> getCache ( ) ) $ AnnotationReader -> setCache ( $ this -> getCache ( ) ) ; $ AnnotationReader -> setDebug ( $ this -> getConfig ( ) [ 'debug' ] ) ; return $ AnnotationReader ; }
Get the hooks annotations reader dependency .
7,858
public function getControllersAnnotationReader ( ) { $ AnnotationReader = new \ Asgard \ Http \ AnnotationReader ; if ( $ this -> getCache ( ) ) $ AnnotationReader -> setCache ( $ this -> getCache ( ) ) ; $ AnnotationReader -> setDebug ( $ this -> getConfig ( ) [ 'debug' ] ) ; return $ AnnotationReader ; }
Get the controllers annotations reader dependency .
7,859
protected function doGetBundles ( ) { $ cache = $ this -> getCache ( ) ; if ( $ cache ) $ bundles = $ cache -> fetch ( 'asgard.bundles' ) ; if ( ! isset ( $ bundles ) || $ bundles === false ) { $ bundles = array_merge ( $ this -> addedBundles , $ this -> getBundles ( ) ) ; $ newBundles = false ; foreach ( $ bundles as ...
Actually fetch all the budles .
7,860
public function getCompiledFile ( ) { if ( $ this -> compiledFile === null ) $ this -> compiledFile = $ this -> params [ 'root' ] . '/storage/compiled.php' ; return $ this -> compiledFile ; }
Get the compiled classes file .
7,861
protected function saveTblNameInSession ( $ name ) { if ( $ session = Yii :: $ app -> getComponents ( ) ) { if ( isset ( $ session [ 'session' ] ) ) { if ( $ mName = Yii :: $ app -> session -> get ( $ this -> tableName ) ) { return $ mName ; } Yii :: $ app -> session -> set ( $ this -> tableName , $ name ) ; return $ n...
Save migration name in session
7,862
public function resetSessionMigrationName ( ) { if ( $ session = Yii :: $ app -> getComponents ( ) ) { if ( isset ( $ session [ 'session' ] ) ) { Yii :: $ app -> session -> set ( $ this -> tableName , null ) ; } } }
Reset migration name in session
7,863
public function getMigrationName ( $ name = '' ) { $ name = $ name ? : $ this -> prefix . $ this -> tableNameRaw ; $ components = Yii :: $ app -> getComponents ( ) ; if ( isset ( $ components [ 'session' ] ) ) { Yii :: $ app -> session -> set ( $ this -> tableName , '' ) ; } $ this -> migrationName = $ this -> migratio...
Auto generate migration name
7,864
public function getCountryCode ( ) { $ countryCode = '' ; $ iban = $ this -> getIban ( ) ; if ( ! empty ( $ iban ) ) { $ countryCode = substr ( $ iban , 0 , 2 ) ; } return $ countryCode ; }
returns the country code of a iban the country code is corresponding to ISO 3166 - 1
7,865
public function getCheckDigits ( ) { $ checkDigits = '' ; $ iban = $ this -> getIban ( ) ; if ( ! empty ( $ iban ) ) { $ checkDigits = substr ( $ iban , 2 , 2 ) ; } return $ checkDigits ; }
return the check digits of a iban check digits corresponding to ISO 7064
7,866
public function prepareCheckDigitsCalculate ( $ iban ) { $ firstPlaces = substr ( ( string ) $ iban , 0 , 2 ) ; $ lastPlaces = substr ( ( string ) $ iban , 4 ) ; $ conversion = strtr ( ( string ) $ lastPlaces . ( string ) $ firstPlaces . '00' , $ this -> charMatching ) ; return $ conversion ; }
prepare check digits calculate
7,867
public function add ( NodeInterface $ node ) { $ max = $ this -> getMax ( ) ; $ node -> setLeftValue ( $ max + 1 ) ; $ node -> setRightValue ( $ max + 2 ) ; $ node -> setLevel ( 0 ) ; }
Adds the new node to the repository
7,868
public function getRootNodes ( ) { $ searchCondition = $ this -> createSearchCondition ( ) ; $ searchCondition -> levelEqualsTo ( 0 ) ; $ rootNodes = $ this -> search ( $ searchCondition ) ; return $ rootNodes ; }
Get root nodes array
7,869
public function drawTree ( ) { $ searchCondition = $ this -> createSearchCondition ( ) ; $ orderRule = $ this -> createSelectOrderRule ( ) -> byLeftAscending ( ) ; $ nodes = $ this -> search ( $ searchCondition , $ orderRule ) ; $ output = Node \ NodeAbstraction :: output ( $ nodes ) ; return $ output ; }
Output the dump of the whole node tree
7,870
public function relation ( $ relationName ) { if ( ! $ this -> dataMapper -> hasRelation ( $ this -> definition , $ relationName ) ) throw new \ Exception ( 'Relation ' . $ relationName . ' does not exist.' ) ; $ relation = $ this -> dataMapper -> relation ( $ this -> definition , $ relationName ) ; $ reverseRelation =...
Return a new ORM for the given relation .
7,871
protected function updateConditions ( array $ conditions , $ table , $ alias ) { $ res = [ ] ; foreach ( $ conditions as $ k => $ v ) { if ( is_array ( $ v ) ) $ v = $ this -> updateConditions ( $ v , $ table , $ alias ) ; else $ v = preg_replace ( '/(?<![\.a-zA-Z0-9-_`\(\)])' . $ table . '\./' , $ alias . '.' , $ v ) ...
Replace the old table with the new alias .
7,872
protected function getNewAlias ( $ name , array $ existing ) { $ i = 1 ; $ alias = $ name ; while ( in_array ( $ alias , $ existing ) ) $ alias = $ name . $ i ++ ; return $ alias ; }
Get new alias if current already exists .
7,873
protected function hydrate ( \ Asgard \ Entity \ Entity $ entity , array $ raw ) { $ this -> unserialize ( $ entity , $ raw ) ; $ entity -> setParameter ( 'persisted' , true ) ; $ entity -> resetChanged ( ) ; return $ entity ; }
Converts a raw array to an entity .
7,874
protected function unserialize ( \ Asgard \ Entity \ Entity $ entity , array $ data , $ locale = null ) { foreach ( $ this -> dataMapper -> getEntityDefinition ( $ entity ) -> properties ( ) as $ k => $ prop ) { $ v = isset ( $ data [ $ k ] ) ? $ data [ $ k ] : null ; if ( $ prop -> get ( 'type' ) === 'entity' ) { if (...
Fills up an entity with a raw array of data .
7,875
public function _getDAL ( ) { $ dal = new \ Asgard \ Db \ DAL ( $ this -> dataMapper -> getDB ( ) ) ; $ table = $ this -> getTable ( ) ; $ dal -> orderBy ( $ this -> orderBy ) ; if ( $ this -> reversed ) $ dal -> reverse ( ) ; $ dal -> limit ( $ this -> limit ) ; $ dal -> offset ( $ this -> offset ) ; if ( $ this -> gr...
Build the DAL .
7,876
protected function recursiveJointures ( \ Asgard \ Db \ DAL $ dal , $ jointures , \ Asgard \ Entity \ Definition $ definition , $ table ) { $ alias = null ; if ( is_array ( $ jointures ) ) { foreach ( $ jointures as $ relation => $ v ) { if ( preg_match ( '/^[^ ]+join /' , $ relation , $ matches ) ) { $ type = trim ( $...
Performs jointures on the DAL object .
7,877
protected function replaceTable ( $ sql ) { $ table = $ this -> getTable ( ) ; $ i18nTable = $ this -> getTranslationTable ( ) ; preg_match_all ( '/(?<![\.a-zA-Z0-9-_`\(\)])([a-z_][a-zA-Z0-9-_]*)(?![\.`\(\)])/' , $ sql , $ matches ) ; foreach ( $ matches [ 0 ] as $ property ) { if ( $ this -> definition -> hasProperty ...
Set the tables .
7,878
protected function processConditions ( array $ conditions ) { foreach ( $ cp = $ conditions as $ k => $ v ) { if ( is_numeric ( $ k ) || in_array ( strtolower ( $ k ) , [ 'and' , 'or' , 'xor' , 'not' ] ) ) { $ newK = $ k ; if ( is_array ( $ v ) ) $ v = $ this -> processConditions ( $ v ) ; else $ v = $ this -> replaceT...
Format the conditions before being used in SQL .
7,879
public function rewind ( ) { if ( ! $ this -> tmp_dal ) $ this -> tmp_dal = $ this -> getDAL ( ) ; $ this -> tmp_dal -> rewind ( ) ; }
Rewind query .
7,880
public function current ( ) { if ( ! ( $ r = $ this -> tmp_dal -> current ( ) ) ) return null ; else { $ entity = $ this -> definition -> make ( [ ] , $ this -> locale ) ; return $ this -> hydrate ( $ entity , $ r ) ; } }
Return current entity .
7,881
public function union ( $ dals ) { if ( ! is_array ( $ dals ) ) $ dals = [ $ dals ] ; $ this -> unions = array_merge ( $ this -> unions , $ dals ) ; return $ this ; }
Add UNIONs .
7,882
public function getContentForRoute ( ) { $ route = $ this -> di -> request -> getRoute ( ) ; $ parts = $ this -> di -> request -> getRouteParts ( ) ; $ toc = $ this -> getTableOfContent ( $ parts [ 0 ] ) ; $ route = $ this -> mapRoute2Toc ( $ route , $ toc ) ; $ baseroute = dirname ( $ route ) ; $ filter = $ this -> co...
Map url to page if such mapping can be done .
7,883
public function mapRoute2Toc ( $ route , $ toc ) { if ( key_exists ( $ route , $ toc ) ) { return $ route ; } elseif ( key_exists ( $ route . "/index" , $ toc ) ) { return $ route . "/index" ; } throw new \ Anax \ Exception \ NotFoundException ( t ( 'The page does not exists.' ) ) ; }
Map the route to the correct entry in the toc .
7,884
public function getTitleFromFirstLine ( $ file ) { $ content = file_get_contents ( $ file , false , null , - 1 , 512 ) ; $ title = strstr ( $ content , "\n" , true ) ; return $ title ; }
Extract title from content .
7,885
public function getTableOfContent ( $ id ) { if ( $ this -> toc ) { return $ this -> toc ; } $ key = $ this -> di -> cache -> createKey ( __CLASS__ , 'toc-' . $ id ) ; $ this -> toc = $ this -> di -> cache -> get ( $ key ) ; if ( ! $ this -> toc ) { $ this -> toc = $ this -> createTableOfContent ( ) ; $ this -> di -> c...
Get table of content for all pages .
7,886
public function createTableOfContent ( ) { $ basepath = $ this -> config [ 'basepath' ] ; $ pattern = $ this -> config [ 'pattern' ] ; $ route = $ this -> di -> request -> getRoute ( ) ; $ baseroute = dirname ( $ route ) ; $ path = $ basepath . '/' . $ baseroute . '/' . $ pattern ; $ toc = [ ] ; foreach ( glob ( $ path...
Generate ToC from directory structure containing url title and filename of each page .
7,887
public function updateItemTableFormatting ( & $ formatting ) { foreach ( $ this -> owner -> Values ( ) as $ field ) { $ fieldVal = $ field -> getFormattedValue ( ) ; $ this -> owner -> { $ field -> Name } = $ fieldVal ; } }
Add in the form values against the submitted form object
7,888
public function setHeader ( string $ header , string $ content ) : Headers { $ this -> headers [ self :: processKey ( $ header ) ] = $ content ; return $ this ; }
Set individual header
7,889
public function setHeaders ( array $ headers = [ ] ) : Headers { $ this -> headers = array ( ) ; foreach ( $ headers as $ header => $ data ) { $ this -> setHeader ( ( string ) $ header , ( string ) $ data ) ; } return $ this ; }
Set headers array . Old headers will be removed
7,890
public function headerExists ( string $ header ) : bool { return array_key_exists ( self :: processKey ( $ header ) , $ this -> getHeaders ( ) ) ; }
Returns true if headers exists false otherwise
7,891
public static function parseHeaders ( string $ headers ) : array { $ parsedHeaders = array ( ) ; foreach ( explode ( "\n" , $ headers ) as $ header ) { @ list ( $ headerTitle , $ headerValue ) = explode ( ':' , $ header , 2 ) ; if ( ! isset ( $ headerValue ) ) { continue ; } $ headerTitle = self :: processKey ( trim ( ...
Parse headers string into associative array . Only named headers returned
7,892
protected function validateBlockLayout ( array $ data ) { foreach ( array_keys ( static :: getDevices ( ) ) as $ device ) { if ( ! isset ( $ data [ $ device ] ) ) { continue ; } $ size = isset ( $ data [ $ device ] [ static :: SIZE ] ) ? $ data [ $ device ] [ static :: SIZE ] : 12 ; $ offset = isset ( $ data [ $ device...
Validates the block layout .
7,893
protected function cleanUpBlockLayout ( Model \ BlockInterface $ block , array $ data ) { $ clean = [ ] ; if ( isset ( $ data [ static :: PADDING_TOP ] ) && 0 < $ data [ static :: PADDING_TOP ] ) { $ clean [ static :: PADDING_TOP ] = $ data [ static :: PADDING_TOP ] ; } if ( isset ( $ data [ static :: PADDING_BOTTOM ] ...
Cleans up the block layout .
7,894
protected function validateLayoutStyles ( array $ layout ) { if ( isset ( $ layout [ static :: PADDING_TOP ] ) && ( 0 > $ layout [ static :: PADDING_TOP ] || 300 < $ layout [ static :: PADDING_TOP ] ) ) { throw new InvalidArgumentException ( 'Invalid layout padding top' ) ; } if ( isset ( $ layout [ static :: PADDING_B...
Validates the layout styles .
7,895
protected function applyLayoutStyles ( View \ AttributesInterface $ attributes , array $ layout ) { foreach ( [ static :: PADDING_TOP => '%spx' , static :: PADDING_BOTTOM => '%spx' ] as $ property => $ template ) { if ( isset ( $ layout [ $ property ] ) && 0 < $ layout [ $ property ] ) { $ attributes -> addStyle ( str_...
Adds the css styles regarding to the layout data .
7,896
protected function getCurrentBlockProperty ( Model \ BlockInterface $ block , $ property , $ default ) { $ layout = $ block -> getLayout ( ) ; $ currentSize = $ default ; foreach ( $ this -> resolveLowerDevices ( ) as $ d ) { if ( isset ( $ layout [ $ d ] ) && isset ( $ layout [ $ d ] [ $ property ] ) ) { $ currentSize...
Returns the current block layout property .
7,897
protected function setCurrentBlockProperty ( Model \ BlockInterface $ block , $ property , $ current ) { $ layout = $ block -> getLayout ( ) ; $ currentDevice = $ this -> resolveCurrentDevice ( ) ; $ layout = array_replace_recursive ( $ layout , [ $ currentDevice => [ $ property => $ current , ] , ] ) ; foreach ( $ thi...
Cleans up the block layout property .
7,898
private function resolveCurrentDevice ( ) { if ( 0 == $ viewportWidth = $ this -> editor -> getViewportWidth ( ) ) { throw new RuntimeException ( 'Unexpected editor viewport width.' ) ; } foreach ( static :: getDevices ( ) as $ device => $ config ) { if ( $ viewportWidth >= $ config [ 'max' ] ) { return $ device ; } } ...
Resolves the current device constant regarding to the editor s viewport width .
7,899
private function resolveGreaterDevices ( ) { if ( 0 == $ viewportWidth = $ this -> editor -> getViewportWidth ( ) ) { throw new RuntimeException ( 'Unexpected editor viewport width.' ) ; } $ devices = [ ] ; foreach ( static :: getDevices ( ) as $ device => $ config ) { if ( $ device === static :: XS ) { continue ; } if...
Resolves the devices constants greater than the editor s viewport width .