idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
54,600
public function PrependExternal ( $ path = '' , $ async = FALSE , $ defer = FALSE , $ doNotMinify = FALSE ) { return $ this -> Prepend ( $ path , $ async , $ defer , $ doNotMinify , TRUE ) ; }
Prepend script before all group scripts for later render process with downloading external content
54,601
public function OffsetExternal ( $ index = 0 , $ path = '' , $ async = FALSE , $ defer = FALSE , $ doNotMinify = FALSE ) { return $ this -> Offset ( $ index , $ path , $ async , $ defer , $ doNotMinify , TRUE ) ; }
Add script into given index of scripts group array for later render process with downloading external content
54,602
public function Append ( $ path = '' , $ async = FALSE , $ defer = FALSE , $ doNotMinify = FALSE , $ external = FALSE ) { $ item = $ this -> _completeItem ( $ path , $ async , $ defer , $ doNotMinify , $ external ) ; $ actialGroupItems = & $ this -> _getScriptsGroupContainer ( $ this -> actualGroupName ) ; array_push ( $ actialGroupItems , $ item ) ; return $ this ; }
Append script after all group scripts for later render process
54,603
public function Prepend ( $ path = '' , $ async = FALSE , $ defer = FALSE , $ doNotMinify = FALSE , $ external = FALSE ) { $ item = $ this -> _completeItem ( $ path , $ async , $ defer , $ doNotMinify , $ external ) ; $ actualGroupItems = & $ this -> _getScriptsGroupContainer ( $ this -> actualGroupName ) ; array_unshift ( $ actualGroupItems , $ item ) ; return $ this ; }
Prepend script before all group scripts for later render process
54,604
public function Offset ( $ index = 0 , $ path = '' , $ async = FALSE , $ defer = FALSE , $ doNotMinify = FALSE , $ external = FALSE ) { $ item = $ this -> _completeItem ( $ path , $ async , $ defer , $ doNotMinify , $ external ) ; $ actialGroupItems = & $ this -> _getScriptsGroupContainer ( $ this -> actualGroupName ) ; $ newItems = [ ] ; $ added = FALSE ; foreach ( $ actialGroupItems as $ key => & $ groupItem ) { if ( $ key == $ index ) { $ newItems [ ] = $ item ; $ added = TRUE ; } $ newItems [ ] = $ groupItem ; } if ( ! $ added ) $ newItems [ ] = $ item ; self :: $ scriptsGroupContainer [ $ this -> getCtrlActionKey ( ) ] [ $ this -> actualGroupName ] = $ newItems ; return $ this ; }
Add script into given index of scripts group array for later render process
54,605
private function _isDuplicateScript ( $ path ) { $ result = '' ; $ allGroupItems = & self :: $ scriptsGroupContainer [ $ this -> getCtrlActionKey ( ) ] ; foreach ( $ allGroupItems as $ groupName => $ groupItems ) { foreach ( $ groupItems as $ item ) { if ( $ item -> path == $ path ) { $ result = $ groupName ; break ; } } } return $ result ; }
Is the linked script duplicate?
54,606
public function Render ( $ indent = 0 ) { $ actualGroupItems = & $ this -> _getScriptsGroupContainer ( $ this -> actualGroupName ) ; if ( count ( $ actualGroupItems ) === 0 ) return '' ; $ minify = ( bool ) self :: $ globalOptions [ 'jsMinify' ] ; $ joinTogether = ( bool ) self :: $ globalOptions [ 'jsJoin' ] ; if ( $ joinTogether ) { $ result = $ this -> _renderItemsTogether ( $ this -> actualGroupName , $ actualGroupItems , $ indent , $ minify ) ; } else { $ result = $ this -> _renderItemsSeparated ( $ this -> actualGroupName , $ actualGroupItems , $ indent , $ minify ) ; } return $ result ; }
Render script elements as html code with links to original files or temporary downloaded files
54,607
private function _downloadFileToTmpAndGetNewHref ( $ item , $ minify = FALSE ) { $ path = $ item -> path ; $ tmpFileFullPath = $ this -> getTmpDir ( ) . '/external_js_' . md5 ( $ path ) . '.js' ; if ( self :: $ fileRendering ) { if ( file_exists ( $ tmpFileFullPath ) ) { $ cacheFileTime = filemtime ( $ tmpFileFullPath ) ; } else { $ cacheFileTime = 0 ; } if ( time ( ) > $ cacheFileTime + self :: EXTERNAL_MIN_CACHE_TIME ) { while ( TRUE ) { $ newPath = $ this -> _getPossiblyRedirectedPath ( $ path ) ; if ( $ newPath === $ path ) { break ; } else { $ path = $ newPath ; } } $ fr = fopen ( $ path , 'r' ) ; $ fileContent = '' ; $ bufferLength = 102400 ; $ buffer = '' ; while ( $ buffer = fread ( $ fr , $ bufferLength ) ) { $ fileContent .= $ buffer ; } fclose ( $ fr ) ; if ( $ minify ) { $ fileContent = $ this -> _minify ( $ fileContent , $ path ) ; } $ this -> saveFileContent ( $ tmpFileFullPath , $ fileContent ) ; $ this -> log ( "External js file downloaded ('$tmpFileFullPath')." , 'debug' ) ; } } $ tmpPath = substr ( $ tmpFileFullPath , strlen ( $ this -> getAppRoot ( ) ) ) ; return $ tmpPath ; }
Download js file by path and store result in tmp directory and return new href value
54,608
private function _getPossiblyRedirectedPath ( $ path = '' ) { $ fp = fopen ( $ path , 'r' ) ; $ metaData = stream_get_meta_data ( $ fp ) ; foreach ( $ metaData [ 'wrapper_data' ] as $ response ) { if ( strtolower ( substr ( $ response , 0 , 10 ) ) == 'location: ' ) { $ path = substr ( $ response , 10 ) ; } } return $ path ; }
If there is any redirection in external content path - get redirect path
54,609
private function _renderItemSeparated ( \ stdClass $ item ) { $ result = '<script type="text/javascript"' ; if ( $ item -> async ) $ result .= ' async="async"' ; if ( $ item -> async ) $ result .= ' defer="defer"' ; if ( ! $ item -> external && self :: $ fileChecking ) { $ fullPath = $ this -> getAppRoot ( ) . $ item -> path ; if ( ! file_exists ( $ fullPath ) ) { $ this -> log ( "File not found in CSS view rendering process ('$fullPath')." , 'error' ) ; } } $ result .= ' src="' . $ item -> src . '"></script>' ; return $ result ; }
Create HTML script element from data item
54,610
public function createDecorator ( $ decorable , $ templateTypeName = null ) { if ( $ decorable instanceof ContentInterface ) { return new ImmutableDecorator ( $ decorable , $ this -> contentDecorator , $ this -> currentTheme ? : $ this -> themeResolver -> resolve ( ) , $ templateTypeName ) ; } if ( $ decorable instanceof ComponentInterface ) { return $ this -> componentDecorator ; } throw new \ InvalidArgumentException ( sprintf ( 'Given decorable "%s" is not supported by Synapse. Check your configuration.' , is_object ( $ decorable ) ? get_class ( $ decorable ) : gettype ( $ decorable ) ) ) ; }
Create and return a DecoratorInterface for given content .
54,611
private function getKeyPath ( Memento \ Key $ key = null ) { $ pathParts = array ( ) ; if ( ! is_null ( $ this -> groupKey ) ) { $ keyFileName = base64_encode ( $ this -> groupKey -> getKey ( ) ) ; $ keyPartition = abs ( crc32 ( $ keyFileName ) ) % Memento \ Engine \ File :: DIR_PARTITION_COUNT ; $ pathParts [ ] = $ keyPartition . DIRECTORY_SEPARATOR . $ keyFileName ; } if ( ! is_null ( $ key ) ) { $ keyFileName = base64_encode ( $ key -> getKey ( ) ) ; $ keyPartition = abs ( crc32 ( $ keyFileName ) ) % Memento \ Engine \ File :: DIR_PARTITION_COUNT ; $ pathParts [ ] = $ keyPartition . DIRECTORY_SEPARATOR . $ keyFileName ; } $ keyPath = $ this -> storagePath . DIRECTORY_SEPARATOR . implode ( DIRECTORY_SEPARATOR , $ pathParts ) ; if ( ! is_dir ( $ keyPath ) ) { @ mkdir ( $ keyPath , 0777 , true ) ; } return $ keyPath ; }
Gets the path to the key Can return group path key path or group path + key path
54,612
private function getExpiresPath ( Memento \ Key $ key = null ) { return $ this -> getKeyPath ( $ this -> groupKey ? null : $ key ) ; }
Gets the path to the expires file Returns group path if possible . Otherwise returns key path
54,613
private function getTtlPath ( Memento \ Key $ key = null ) { return $ this -> getKeyPath ( $ this -> groupKey ? null : $ key ) ; }
Gets the path to the ttl file Returns group path if possible . Otherwise returns key path
54,614
private function rrmdir ( $ dir ) { if ( 0 !== strpos ( $ dir , $ this -> storagePath ) ) { return false ; } foreach ( glob ( $ dir . DIRECTORY_SEPARATOR . '*' ) as $ file ) { if ( is_dir ( $ file ) ) { $ this -> rrmdir ( $ file ) ; } else { unlink ( $ file ) ; } } return rmdir ( $ dir ) ; }
Recursively removes a directory
54,615
public function terminate ( Memento \ Key $ key = null ) { $ keyPath = $ this -> getKeyPath ( $ key ) ; return $ this -> rrmdir ( $ keyPath ) ; }
Duplicate of the invalidate command
54,616
private function filesWithFullPaths ( $ dir , $ include_hidden = true , $ recursive = false ) { $ dir = $ this -> withSlash ( $ dir ) ; $ result = [ ] ; if ( $ dirstream = opendir ( $ dir ) ) { while ( false !== ( $ filename = readdir ( $ dirstream ) ) ) { $ path = $ dir . $ filename ; if ( $ filename != '.' && $ filename != '..' ) { if ( is_dir ( $ path ) ) { if ( $ recursive ) { $ files_from_subdir = $ this -> filesWithFullPaths ( $ path , $ recursive ) ; if ( is_array ( $ files_from_subdir ) ) { $ result = array_merge ( $ result , $ files_from_subdir ) ; } } } else { if ( is_file ( $ path ) || ( is_link ( $ path ) && is_file ( readlink ( $ path ) ) ) ) { if ( mb_substr ( $ filename , 0 , 1 ) == '.' && ! $ include_hidden ) { continue ; } $ result [ ] = $ path ; } } } } } closedir ( $ dirstream ) ; return $ result ; }
Return a list of files from a directory .
54,617
private function deleteDirByFullPath ( $ path , $ delete_self = true , array $ exclude = [ ] ) { $ dir = $ this -> withSlash ( $ path ) ; if ( $ dh = opendir ( $ dir ) ) { while ( $ file = readdir ( $ dh ) ) { if ( ( $ file != '.' ) && ( $ file != '..' ) ) { $ fullpath = $ dir . $ file ; if ( ! $ delete_self && in_array ( $ fullpath , $ exclude ) ) { continue ; } if ( is_link ( $ fullpath ) ) { unlink ( $ fullpath ) ; } else { if ( is_dir ( $ fullpath ) ) { $ this -> deleteDirByFullPath ( $ fullpath ) ; } else { unlink ( $ fullpath ) ; } } } } closedir ( $ dh ) ; } if ( $ delete_self ) { rmdir ( $ dir ) ; } }
Delete directory by full path .
54,618
static function name ( $ ref ) { return implode ( "_" , array_map ( function ( $ ck , $ cr ) { return preg_replace ( "/_$cr\$/" , "" , $ ck ) ; } , $ ref [ "foreignColumns" ] , $ ref [ "referencedColumns" ] ) ) ; }
Compose an identifying name
54,619
public function getPagedResults ( $ limit = 50 , $ page = 0 ) { $ dql = sprintf ( self :: DQL_GET_USERS , User :: class ) ; return $ this -> getPaginator ( $ dql , $ limit , $ page ) ; }
Get all users paged .
54,620
public function transferDiscounts ( Varien_Object $ salesObject , IDiscountContainer $ discountContainer ) { $ discounts = $ discountContainer -> getDiscounts ( ) ; $ data = $ this -> getDiscountsData ( $ salesObject ) ; foreach ( $ data as $ loneDiscountData ) { $ discount = $ this -> _fillOutDiscount ( $ discounts -> getEmptyDiscount ( ) , $ loneDiscountData ) ; $ discounts [ $ discount ] = $ discount ; } return $ discountContainer -> setDiscounts ( $ discounts ) ; }
Transfer discount data from Mage_Sales_Model_Order_Addresses to IDiscountContainer .
54,621
protected function _fillOutDiscount ( IDiscount $ discountPayload , array $ discountData ) { return $ discountPayload -> setAmount ( $ this -> _nullCoalesce ( $ discountData , 'amount' , 0.00 ) ) -> setAppliedCount ( $ this -> _nullCoalesce ( $ discountData , 'applied_count' , null ) ) -> setCode ( $ this -> _nullCoalesce ( $ discountData , 'code' , null ) ) -> setDescription ( $ this -> _nullCoalesce ( $ discountData , 'description' , null ) ) -> setEffectType ( $ this -> _nullCoalesce ( $ discountData , 'effect_type' , null ) ) -> setId ( $ this -> _nullCoalesce ( $ discountData , 'id' , null ) ) ; }
Fill out the data in an IDiscount
54,622
public function transferTaxDiscounts ( Varien_Object $ salesObject , ITaxDiscountContainer $ discountContainer ) { $ discounts = $ discountContainer -> getDiscounts ( ) ; $ data = $ this -> getDiscountsData ( $ salesObject ) ; foreach ( $ data as $ loneDiscountData ) { $ discount = $ this -> _fillOutTaxDiscount ( $ discounts -> getEmptyDiscount ( ) , $ loneDiscountData ) ; ; $ discounts [ $ discount ] = $ discount ; } return $ discountContainer -> setDiscounts ( $ discounts ) ; }
Transfer discount data from Mage_Sales_Model_Qoute_Addresses or Mage_Sales_Model_Quote_Items to TaxDutyFee \ IDiscountContainer .
54,623
public function transferInvoiceTaxDiscounts ( Varien_Object $ salesObject , ITaxedDiscountContainer $ discountContainer ) { $ discounts = $ discountContainer -> getDiscounts ( ) ; $ itemC = Mage :: getModel ( 'sales/order_item' ) -> getCollection ( ) -> addFieldToFilter ( 'item_id' , array ( 'eq' => $ salesObject -> getData ( 'order_item_id' ) ) ) ; if ( $ itemC -> getSize ( ) > 0 ) { $ data = unserialize ( $ itemC -> getFirstItem ( ) -> getData ( 'ebayenterprise_order_discount_data' ) ) ; if ( $ data ) { foreach ( $ data as $ loneDiscountData ) { if ( $ loneDiscountData [ 'amount' ] != 0 ) { $ appliedCount = $ loneDiscountData [ 'applied_count' ] ; $ singleDisc = $ loneDiscountData [ 'amount' ] / $ appliedCount ; $ newAmount = $ singleDisc * $ salesObject -> getQty ( ) ; $ loneDiscountData [ 'amount' ] = $ newAmount ; $ discount = $ this -> _fillOutTaxDiscount ( $ discounts -> getEmptyDiscount ( ) , $ loneDiscountData ) ; ; $ discounts [ $ discount ] = $ discount ; } } } } return $ discountContainer -> setDiscounts ( $ discounts ) ; }
Transfer discount data from Mage_Sales_Model_Qoute_Addresses or Mage_Sales_Model_Quote_Items to TaxDutyFee \ ITaxedDiscountContainer .
54,624
protected function _fillOutTaxDiscount ( ITaxDiscount $ discountPayload , array $ discountData ) { return $ discountPayload -> setAmount ( $ this -> _nullCoalesce ( $ discountData , 'amount' , null ) ) -> setId ( $ this -> _nullCoalesce ( $ discountData , 'id' , null ) ) ; }
Fill out the data in an ITaxDiscount
54,625
public function setPost ( $ spec , $ value = null ) { if ( ( null === $ value ) && ! is_array ( $ spec ) ) { throw new \ Exception ( 'Invalid value passed to setPost(); must be either array of values or key/value pair' ) ; } if ( ( null === $ value ) && is_array ( $ spec ) ) { foreach ( $ spec as $ key => $ value ) { $ this -> setPost ( $ key , $ value ) ; } return $ this ; } $ _POST [ ( string ) $ spec ] = $ value ; return $ this ; }
Set POST values
54,626
public function getRawBody ( ) { if ( null === $ this -> _rawBody ) { $ body = file_get_contents ( 'php://input' ) ; if ( strlen ( trim ( $ body ) ) > 0 ) { $ this -> _rawBody = $ body ; } else { $ this -> _rawBody = false ; } } return $ this -> _rawBody ; }
Return the raw body of the request if present
54,627
private function bindApplicationEvent ( ServiceDefinition $ application , string $ event , string $ class , string $ property , string $ argument = null ) : void { $ argument = $ argument ? ', $' . $ argument : '' ; $ application -> addSetup ( sprintf ( '?->?[] = function ($application%s = null) use ($dispatcher) { $dispatcher->dispatch(?, new %s($application%s)); }' , $ argument , $ class , $ argument ) , [ '@self' , $ property , $ event , ] ) ; }
Binds dispatcher to Nette \ Application \ Application event .
54,628
public function initDb ( array $ connections ) : void { $ this -> db = new Database ( ) ; foreach ( $ connections as $ name => $ settings ) { $ this -> db -> addConnection ( $ settings , $ name ) ; } }
Prepares the database interaction
54,629
public function load ( bool $ debug = false ) : void { $ this -> app = new Slim ( [ 'settings' => [ 'displayErrorDetails' => $ debug ] ] ) ; if ( ! $ debug ) { Error :: registerSystemErrors ( $ this -> app ) ; } $ this -> buildRoutes ( ) ; }
Loads the main routing framework and builds the application routes
54,630
private function buildRoutes ( ) : void { require_once 'System.php' ; System :: reflectionRoutes ( $ this , $ this -> app ) ; foreach ( $ this -> types as $ type ) { $ type -> applyRoutes ( $ this , $ this -> app ) ; } }
Adds all routes to the System
54,631
public function addValidation ( string $ name , string $ validation ) : void { $ this -> validations [ $ name ] = $ validation ; }
Adds a new validation option to the application
54,632
public function addCalculator ( string $ name , string $ validation ) : void { $ this -> calculators [ $ name ] = $ validation ; }
Adds a new calculator option to the application
54,633
public function addFilter ( string $ name , string $ filter ) : void { $ this -> filters [ $ name ] = $ filter ; }
Adds a new Filter option to the application
54,634
public function addMiddleware ( string $ name , string $ middleware ) : void { $ this -> middleware [ $ name ] = $ middleware ; }
Adds a new Middleware option to the application
54,635
public function addRoute ( string $ type , string $ name , string $ route ) : void { if ( ! isset ( $ this -> routes [ $ name ] ) ) { $ this -> routes [ $ name ] = [ ] ; } $ this -> routes [ $ name ] [ $ type ] = $ route ; }
Adds a new Route option to the application
54,636
public function getRoute ( string $ type , string $ name ) : string { return $ this -> routes [ $ name ] [ $ type ] ; }
Returns the classname of the given Route option
54,637
public function addType ( string $ name , string $ type ) : void { $ this -> types [ $ name ] = new Type ( $ type ) ; }
Add a content type to the CDL System
54,638
public function addMigration ( string $ path , Migration $ migrations ) : void { $ name = basename ( $ path ) ; $ this -> migrations [ $ name ] = $ migrations ; }
Adds a new Migration option to the application
54,639
protected function _setNamespaceFromGetters ( array $ gettersNamespaces ) { ( $ this -> _c__namespace ) ? : $ this -> _c__namespace = $ this -> namespace ; $ this -> setNamespace ( $ gettersNamespaces ) ; $ this -> namespace_getter = array ( ) ; return $ this ; }
Set Namespace From Getters - save current namespace state - reset getters namespace state - set namespace to getters
54,640
public function onKernelRequest ( GetResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ route = $ this -> router -> getRouteCollection ( ) -> get ( $ request -> attributes -> get ( '_route' ) ) ; if ( ! $ route || ! $ themeOptions = $ route -> getOption ( 'synapse_theme' ) ) { return ; } $ request -> attributes -> set ( 'synapse_theme' , $ this -> match ( $ themeOptions , new ThemeMatchingContext ( array ( 'host' => $ request -> server -> get ( 'HTTP_HOST' ) , ) ) ) ) ; }
kernel . request event handler .
54,641
public function handleContextAnnotation ( $ e ) { $ annotation = $ e -> getParam ( 'annotation' ) ; if ( ! $ annotation instanceof Annotation \ Context ) { return ; } $ spec = $ e -> getParam ( $ this -> getEventParamName ( ) ) ; $ spec [ 'contexts' ] = $ annotation -> getContext ( ) ; }
Handle context annotation
54,642
public function execute ( ) { if ( ! $ this -> preExecute ( $ this ) ) { return ; } $ limit = $ this -> datasourceQuery -> getLimit ( ) ; $ offset = $ this -> datasourceQuery -> getOffset ( ) ; $ this -> totalCount = ( int ) $ this -> getCountQuery ( ) -> execute ( ) -> fetchField ( ) ; $ this -> range ( $ offset , $ limit ) ; return $ this -> query -> execute ( ) ; }
Override the execute method .
54,643
public function setAuthors ( array $ authors ) { if ( count ( $ authors ) == 0 ) { return ; } foreach ( $ authors as $ author ) { $ this -> authors [ ] = ( object ) $ author ; } return $ this ; }
Sets the package authors .
54,644
public static function parseVendorAndPackage ( $ templateName ) { if ( $ templateName !== null ) { $ nameParts = explode ( '/' , $ templateName ) ; if ( count ( $ nameParts ) == 2 ) { if ( strlen ( $ nameParts [ 0 ] ) > 0 && strlen ( $ nameParts [ 1 ] ) > 0 ) { return $ nameParts ; } } } throw new InvalidArgumentException ( 'The package name "' . $ templateName . '" is invalid. Expected format "vendor/package".' ) ; }
Parses the package and vendor names .
54,645
public static function getConfiguredPackage ( ) { $ package = new Package ; $ package -> setLicense ( user_config ( 'configuration.license' ) ) ; $ package -> setAuthors ( user_config ( 'configuration.authors' ) ) ; return $ package ; }
Returns a new Package instance configured with user preferences .
54,646
public static function fromArray ( array $ array , $ strict = true ) { $ details = ( object ) $ array ; $ packageNameDetails = self :: parseVendorAndPackage ( object_get ( $ details , 'name' , null ) ) ; $ description = object_get ( $ details , 'description' , null ) ; $ license = object_get ( $ details , 'license' , null ) ; $ authors = object_get ( $ details , 'authors' , null ) ; if ( $ strict ) { self :: throwInvalidArgumentException ( $ description , 'Invalid package description.' ) ; self :: throwInvalidArgumentException ( $ license , 'Invalid package license.' ) ; self :: throwInvalidArgumentException ( $ authors , 'Invalid package authors.' ) ; } $ package = new Package ; $ package -> setAuthors ( $ authors ) ; $ package -> setDescription ( $ description ) ; $ package -> setLicense ( $ license ) ; $ package -> setVendor ( $ packageNameDetails [ 0 ] ) ; $ package -> setPackage ( $ packageNameDetails [ 1 ] ) ; return $ package ; }
Returns a new package instance from the provided array .
54,647
public static function fromFile ( $ path , $ strict = true ) { if ( file_exists ( $ path ) ) { return self :: fromArray ( json_decode ( file_get_contents ( $ path ) , true ) , $ strict ) ; } else { return new Package ; } }
Returns a new package instance from the provided file .
54,648
public function toJson ( ) { $ packageDetails = new \ stdClass ; $ packageDetails -> name = $ this -> getName ( ) ; $ packageDetails -> description = $ this -> getDescription ( ) ; $ packageDetails -> license = $ this -> getLicense ( ) ; $ packageDetails -> authors = $ this -> getAuthors ( ) ; return json_encode ( $ packageDetails , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) ; }
Converts the package details into JSON .
54,649
public function setGeometry ( Geometry $ geometry = null , bool $ stopPropagation = false ) { $ this -> geometry = $ geometry ; if ( $ stopPropagation ) { $ this -> stopPropagation ( ) ; } }
Sets the newly constructed Geometry object .
54,650
public static function loadDotFile ( $ path ) { $ file = file_get_contents ( $ path ) ; if ( $ file === false ) { return null ; } $ file = str_replace ( "\r" , "\n" , $ file ) ; $ file = str_replace ( "\n\n" , "\n" , $ file ) ; $ lines = explode ( "\n" , $ file ) ; $ data = [ ] ; $ lineCount = count ( $ lines ) ; for ( $ i = 0 ; $ i < $ lineCount ; $ i ++ ) { $ line = trim ( $ lines [ $ i ] ) ; if ( strlen ( $ line ) === 0 ) { continue ; } $ split = explode ( '=' , $ line , 2 ) ; if ( count ( $ split ) < 2 ) { throw new Exception \ ConfigurationException ( "Invalid data in .bitrank file on line $i. ($line)" ) ; } $ key = $ split [ 0 ] ; $ value = $ split [ 1 ] ; $ data [ $ key ] = $ value ; } return $ data ; }
Loads the . bitrank file if there is one .
54,651
public static function getProjectRoot ( ) { $ sep = DIRECTORY_SEPARATOR ; $ pos = strrpos ( __DIR__ , "${sep}vendor${sep}" ) ; if ( $ pos === false ) { return null ; } $ projectRoot = substr ( __DIR__ , 0 , $ pos ) ; return $ projectRoot ; }
Gets the project root directory if possible .
54,652
public function update ( ) { $ item = $ this -> cache -> getItem ( "io.bitrank.$this->cacheHandle.init-data" ) ; $ init_data = $ item -> get ( ) ; if ( $ item -> isMiss ( ) ) { if ( $ this -> getTestParam ( 'cache-must-hit' ) ) { throw new \ Exception ( "Cache did not hit" ) ; } $ item -> lock ( ) ; if ( $ this -> requestStartTime == 0 ) { $ this -> requestStartTime = microtime ( true ) ; } try { $ init_data = $ this -> retrieveInitData ( ) ; } catch ( Exception \ RateLimitExceededException $ rlx ) { unset ( $ item ) ; if ( ( microtime ( true ) - $ this -> requestStartTime ) < $ this -> timeout ) { usleep ( 100 ) ; $ this -> update ( ) ; return ; } else { throw new TimeoutExceededException ( 'The server was rate limiting the client, and retries could not be completed within the configured time limit' ) ; } } $ item -> set ( $ init_data ) ; $ this -> cache -> save ( $ item ) ; } else { if ( $ this -> getTestParam ( 'cache-must-miss' ) ) { throw new \ Exception ( "Cache did hit" ) ; } $ this -> dataVersion = $ init_data [ 'dataVersion' ] ; } $ this -> localeData = $ init_data [ 'locale' ] ; $ this -> flags = Flag :: parseAPI ( $ this , $ init_data [ 'flags' ] ) ; $ this -> scores = ScoreTiers :: parseAPI ( $ this , $ init_data [ 'scores' ] ) ; $ this -> requestStartTime = 0 ; }
Updates the initialisation data for flags scores and locale .
54,653
private function processHttpResponse ( $ response ) { $ statusCode = $ response -> getStatusCode ( ) ; switch ( $ statusCode ) { case 200 : break ; case 404 : break ; case 400 : throw new Exception \ ClientRequestException ( "The server rejected our request. Are you using a deprecated version of the BitRank PHP client?" ) ; case 401 : throw new Exception \ AuthException ( "The server reject our API key." ) ; case 403 : $ data = json_decode ( $ response -> getBody ( ) , true ) ; if ( isset ( $ data [ 'errorCode' ] ) && $ data [ 'errorCode' ] === 'API_LIMIT_EXCEEDED' ) { throw new Exception \ RequestLimitExceededException ( ) ; } else { $ message = '' ; if ( isset ( $ data [ 'message' ] ) ) { $ message = $ data [ 'message' ] ; } throw new Exception \ AuthException ( "The server rejected our API key: " . $ message ) ; } case 429 : throw new Exception \ RateLimitExceededException ( ) ; case 500 : throw new Exception \ ServerErrorException ( "The server reported that an internal error occured during the processing of this request." ) ; } return $ statusCode ; }
Process HTTP request codes
54,654
private function retrieveInitData ( ) { try { $ response = $ this -> client -> request ( 'GET' , "/v2/init-data/$this->locale" , $ this -> authHeaders ) ; $ this -> processHttpResponse ( $ response ) ; } catch ( \ GuzzleHttp \ Exception \ TransferException $ tex ) { throw new Exception \ ConnectionFailedException ( 'Failed to connect to the BitRank API' , $ tex ) ; } $ init_data = json_decode ( $ response -> getBody ( ) , true ) ; $ required = [ 'flags' , 'scores' , 'locale' ] ; foreach ( $ required as $ req ) { if ( ! isset ( $ init_data [ $ req ] ) ) { throw new Exception \ InvalidDataException ( "Initialisation data did not contain $req data." ) ; } } $ this -> dataVersion = $ response -> getHeader ( 'X-Data-Version' ) ; if ( is_string ( $ this -> dataVersion ) ) { } elseif ( is_array ( $ this -> dataVersion ) && count ( $ this -> dataVersion ) ) { $ this -> dataVersion = $ this -> dataVersion [ 0 ] ; } else { throw new Exception \ InvalidDataException ( 'The init data response did not contain a valid X-Data-Version header.' ) ; } $ init_data [ 'dataVersion' ] = $ this -> dataVersion ; return $ init_data ; }
Retrieve init data from the server .
54,655
private function requestScore ( $ addressBase58 ) { try { if ( $ this -> requestStartTime == 0 ) { $ this -> requestStartTime = microtime ( true ) ; } $ response = $ this -> client -> request ( 'GET' , "/v2/address/$addressBase58/score" , $ this -> authHeaders ) ; } catch ( RequestException $ rex ) { throw new Exception \ TimeoutExceededException ( 'The server did not respond within the allocated time limit.' ) ; } catch ( GuzzleException $ gex ) { throw new Exception \ ConnectionFailedException ( 'Failed to connect to the BitRank API' , $ gex ) ; } try { $ statusCode = $ this -> processHttpResponse ( $ response ) ; } catch ( Exception \ RateLimitExceededException $ rlx ) { if ( ( microtime ( true ) - $ this -> requestStartTime ) < $ this -> timeout ) { usleep ( 100 ) ; return $ this -> requestScore ( $ addressBase58 ) ; } else { throw $ rlx ; } } $ this -> requestStartTime = 0 ; if ( 200 == $ statusCode ) { $ seen = true ; $ dataVersion = $ response -> getHeader ( 'X-Data-Version' ) ; if ( is_string ( $ dataVersion ) ) { } elseif ( is_array ( $ dataVersion ) && count ( $ dataVersion ) ) { $ dataVersion = $ dataVersion [ 0 ] ; } else { throw new Exception \ InvalidDataException ( 'Expected X-Data-Version data from API' ) ; } if ( $ this -> dataVersion !== $ dataVersion ) { $ this -> cache -> clear ( ) ; $ this -> update ( ) ; if ( $ this -> dataVersion != $ dataVersion ) { throw new Exception \ InvalidDataException ( 'The Score X-Data-Version does not match the Init Data X-Data-Version' ) ; } } } else { $ seen = false ; } return [ $ seen , $ response -> getBody ( ) ] ; }
Makes a generic score request to the API and returns the data for further processing .
54,656
public function score ( $ addressBase58 ) { $ response = $ this -> requestScore ( $ addressBase58 ) ; $ seen = $ response [ 0 ] ; $ body = json_decode ( $ response [ 1 ] , true ) ; return new Score ( $ this , $ addressBase58 , $ body , $ seen ) ; }
Retrieves the BitRank score of the address you are requesting .
54,657
public function getLocaleString ( $ key ) { $ level = & $ this -> localeData ; $ keys = explode ( '.' , $ key ) ; foreach ( $ keys as $ key ) { if ( isset ( $ level [ $ key ] ) ) { $ level = & $ level [ $ key ] ; } else { return null ; } } return $ level ; }
Returns a locale string based on the given key .
54,658
public function getFlag ( $ key ) { if ( isset ( $ this -> flags [ $ key ] ) ) { return $ this -> flags [ $ key ] ; } return null ; }
Get a flag by its key
54,659
private function processContentPhaseTwo ( & $ filtered ) { $ filter = $ this -> config [ "textfilter" ] ; $ textFilter = $ this -> di -> get ( "textfilter" ) ; $ new = $ textFilter -> parse ( $ filtered -> text , $ filter ) ; $ filtered -> text = $ new -> text ; $ filtered -> frontmatter = array_merge_recursive_distinct ( $ filtered -> frontmatter , $ new -> frontmatter ) ; $ baseurl = isset ( $ filtered -> frontmatter [ "baseurl" ] ) ? $ filtered -> frontmatter [ "baseurl" ] : null ; $ this -> addBaseurl2AnchorUrls ( $ filtered , $ baseurl ) ; $ this -> addBaseurl2ImageSource ( $ filtered , $ baseurl ) ; $ textFilter -> addExcerpt ( $ filtered ) ; }
Process content phase 2 and merge with new frontmatter into view structure .
54,660
private function getDataForAdditionalRoute ( $ route ) { $ filter = $ this -> config [ "textfilter" ] ; $ textFilter = $ this -> di -> get ( "textfilter" ) ; list ( $ routeIndex , , $ filtered ) = $ this -> mapRoute2Content ( $ route ) ; $ meta = $ this -> getMetaForRoute ( $ route ) ; unset ( $ meta [ "__toc__" ] ) ; unset ( $ meta [ "views" ] ) ; $ new = $ textFilter -> parse ( $ filtered -> text , $ filter ) ; $ new -> frontmatter = array_merge_recursive_distinct ( $ filtered -> frontmatter , $ new -> frontmatter ) ; $ baseurl = isset ( $ new -> frontmatter [ "data" ] [ "baseurl" ] ) ? isset ( $ new -> frontmatter [ "data" ] [ "baseurl" ] ) : null ; $ this -> addBaseurl2AnchorUrls ( $ new , $ baseurl ) ; $ this -> addBaseurl2ImageSource ( $ new , $ baseurl ) ; $ frontmatter = $ new -> frontmatter ; $ frontmatter [ "data" ] [ "content" ] = $ new -> text ; $ view = [ "main" => $ frontmatter ] ; $ this -> loadAdditionalContent ( $ view , $ route , $ routeIndex ) ; return $ view [ "main" ] ; }
Load view data for additional route merged with meta if any .
54,661
private function addBaseurl2AnchorUrls ( & $ filtered , $ baseurl ) { $ textf = $ this -> di -> get ( "textfilter" ) ; $ url = $ this -> di -> get ( "url" ) ; $ request = $ this -> di -> get ( "request" ) ; $ part = $ request -> getRoute ( ) ; $ callback = function ( $ route ) use ( $ url , $ baseurl , $ part ) { if ( ! empty ( $ route ) && $ route [ 0 ] == "!" ) { return $ url -> asset ( substr ( $ route , 1 ) , $ baseurl ) ; } if ( isset ( $ route [ 0 ] ) && isset ( $ route [ 1 ] ) && $ route [ 0 ] === "." && $ route [ 1 ] === "/" ) { return $ url -> create ( substr ( $ route , 2 ) , $ baseurl . $ part ) ; } return $ url -> create ( $ route , $ baseurl ) ; } ; $ filtered -> text = $ textf -> addBaseurlToRelativeLinks ( $ filtered -> text , $ baseurl , $ callback ) ; }
Parse text find and update all a href to use baseurl .
54,662
private function addBaseurl2ImageSource ( & $ filtered , $ baseurl ) { $ textf = $ this -> di -> get ( "textfilter" ) ; $ url = $ this -> di -> get ( "url" ) ; $ callback = function ( $ route ) use ( $ url , $ baseurl ) { return $ url -> asset ( $ route , $ baseurl ) ; } ; $ filtered -> text = $ textf -> addBaseurlToImageSource ( $ filtered -> text , $ baseurl , $ callback ) ; }
Parse text find and update all image source to use baseurl .
54,663
public function handleTriggerAnnotation ( $ e ) { $ annotation = $ e -> getParam ( 'annotation' ) ; if ( ! $ annotation instanceof Annotation \ Trigger ) { return ; } $ operationSpec = $ e -> getParam ( 'operationSpec' ) ; $ operationSpec [ 'events' ] [ ] = $ annotation -> getEventDescription ( ) ; }
Handle event trigger annotation
54,664
public function handleAliasAnnotation ( $ e ) { $ annotation = $ e -> getParam ( 'annotation' ) ; if ( ! $ annotation instanceof Annotation \ Alias ) { return ; } $ operationSpec = $ e -> getParam ( 'operationSpec' ) ; $ operationSpec [ 'aliases' ] = ( array ) $ annotation -> getAlias ( ) ; }
Handle alias annotation
54,665
public function getFullPath ( $ path = '/' ) { if ( mb_substr ( $ path , 0 , 1 ) == '/' ) { $ path = mb_substr ( $ path , 1 ) ; } $ full_path = $ this -> getSandboxPath ( ) . $ path ; if ( strpos ( $ full_path , '..' ) ) { $ full_path = realpath ( $ full_path ) ; if ( mb_substr ( $ full_path , 0 , $ this -> sandbox_path_length ) != $ this -> sandbox_path ) { throw new InvalidArgumentException ( '$path is outside of the sanbox path' ) ; } } return $ full_path ; }
Convert relative path to full path .
54,666
public static function getBoxHTML ( $ boxContent ) { $ html = '' ; if ( empty ( $ boxContent ) ) return NULL ; $ html .= '<!-- Start_Box ; $ html .= '<div class="box box-info">' ; $ html .= self :: getBoxHeaderHTML ( $ boxContent [ "header" ] ) ; $ html .= '<div class="box-body">' ; $ html .= self :: getTableHTML ( $ boxContent [ "table" ] ) ; $ html .= '</div>' ; $ html .= self :: getBoxFooterHTML ( $ boxContent [ "footer" ] ) ; $ html .= '</div>' ; $ html .= '<!-- End_Box ; return $ html ; }
Construct HTML for a Box
54,667
public static function getTableHTML ( $ tableData ) { $ html = '' ; if ( empty ( $ tableData ) ) return NULL ; $ html .= '<!-- Start_Table_Responsive ; $ html .= '<div class="table-responsive">' ; $ html .= '<table class="table no-margin">' ; $ html .= '<thead>' ; $ html .= '<tr>' ; foreach ( $ tableData [ "ths" ] as $ th ) { $ html .= '<th>' ; $ html .= $ th ; $ html .= '</th>' ; } $ html .= '</tr>' ; $ html .= '</thead>' ; $ html .= '<tbody>' ; $ html .= '<tr>' ; foreach ( $ tableData [ "tbs" ] as $ tb ) { foreach ( $ tb as $ t ) { $ html .= $ t ; } } $ html .= '</tr>' ; $ html .= '</tbody>' ; $ html .= '</table>' ; $ html .= '</div>' ; $ html .= '<!-- End_Table_Responsive ; return $ html ; }
Construct HTML of all tables
54,668
public static function getBoxHeaderHTML ( $ header ) { $ html = '' ; if ( empty ( $ header ) ) return NULL ; $ html .= '<!-- Start_Box_Header ; $ html .= '<div class="box-header with-border">' ; $ html .= '<h3 class="box-title">' . $ header [ "title" ] . '</h3>' ; $ html .= '<div class="box-tools pull-right">' ; $ html .= '<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>' ; $ html .= '<button class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>' ; $ html .= '</div>' ; $ html .= '<!-- End_Box_Header ; return $ html ; }
Construct HTML for a Box - Header
54,669
public static function getBoxFooterHTML ( $ footer ) { $ html = '' ; if ( empty ( $ footer ) ) return NULL ; $ html .= '<!-- Start_Box_Footer ; $ html .= '<div class="box-footer clearfix">' ; $ html .= '<a href="javascript::;" class="btn btn-sm btn-info btn-flat pull-left">' . $ footer [ "footerLeft" ] . '</a>' ; $ html .= '<a href="javascript::;" class="btn btn-sm btn-default btn-flat pull-right">' . $ footer [ "footerRight" ] . '</a>' ; $ html .= '</div>' ; $ html .= '<!-- End_Box_Footer ; return $ html ; }
Construct HTML for a Box - Footer
54,670
public function coreComponents ( ) { return [ 'naming' => [ 'class' => '\cza\base\components\utils\Naming' , ] , 'password' => [ 'class' => '\cza\base\components\utils\Password' , ] , 'folderOrganizer' => [ 'class' => '\cza\base\components\utils\FolderOrganizer' , 'uploadTempPath' => isset ( Yii :: $ app -> params [ 'config' ] [ 'upload' ] [ 'tempPath' ] ) ? Yii :: $ app -> params [ 'config' ] [ 'upload' ] [ 'tempPath' ] : '@app/web/uploads/temp' , 'uploadStorePath' => isset ( Yii :: $ app -> params [ 'config' ] [ 'upload' ] [ 'storePath' ] ) ? Yii :: $ app -> params [ 'config' ] [ 'upload' ] [ 'storePath' ] : '@app/web/uploads/store' , ] , 'wechatHelper' => [ 'class' => '\cza\base\components\utils\WechatHelper' , ] , 'simpleHTMLDOM' => [ 'class' => '\cza\base\vendor\utils\SimpleHTMLDOM\SimpleHTMLDOM' , ] , ] ; }
Returns the configuration of core application components .
54,671
public function getRegularLangName ( $ lang = NULL ) { if ( isset ( $ this -> _data [ 'env' ] [ 'APP_LANG_NAME' ] ) ) { return $ this -> _data [ 'env' ] [ 'APP_LANG_NAME' ] ; } if ( is_null ( $ lang ) ) $ lang = Yii :: $ app -> language ; $ this -> _data [ 'env' ] [ 'ENABLED_LANGS' ] = str_replace ( "-" , "_" , strtolower ( $ lang ) ) ; return $ this -> _data [ 'env' ] [ 'ENABLED_LANGS' ] ; }
return regular language name eg . zh_cn
54,672
public function getValueByKey ( $ key , $ default = '' , $ class = null ) { if ( null === $ class ) { $ class = $ this -> getEntityClass ( ) ; } $ result = $ this -> getDoctrine ( ) -> getRepository ( $ class ) -> findOneBy ( [ 'key' => $ key , ] ) ; if ( null === $ result ) { return $ default ; } return $ result -> getValue ( ) ; }
Get Value By Key
54,673
private function getEntityClass ( ) { foreach ( $ this -> getDoctrineManager ( ) -> getMetadataFactory ( ) -> getAllMetadata ( ) as $ metaData ) { if ( $ metaData -> getName ( ) === Config :: class ) { continue ; } $ reflectionClass = new \ ReflectionClass ( $ metaData -> getName ( ) ) ; if ( true === in_array ( Config :: class , $ this -> getParentClassNames ( $ reflectionClass ) ) ) { return $ metaData -> getName ( ) ; } } throw new \ RuntimeException ( 'Missing config entity!' ) ; }
Get Entity Class
54,674
private function getParentClassNames ( \ ReflectionClass $ reflectionClass ) { $ parentClassNames = [ ] ; while ( $ parent = $ reflectionClass -> getParentClass ( ) ) { $ parentClassNames [ ] = $ parent -> getName ( ) ; $ reflectionClass = $ parent ; } return $ parentClassNames ; }
Get Parent ClassNames
54,675
public function getFileOutput ( $ filename ) { if ( file_exists ( $ filename ) ) { ob_start ( ) ; include ( $ filename ) ; $ content = ob_get_contents ( ) ; ob_end_clean ( ) ; $ this -> logger -> info ( "View parsed - $filename" ) ; } else { $ content = "" ; } return $ content ; }
This method can be used from controller only from Controller . Its main purpose is to get the content of any view .
54,676
public function massAttachTags ( MassAttachRequest $ request ) { $ data = $ request -> only ( [ 'ids' , 'tag_names' ] ) ; foreach ( $ data [ 'ids' ] as $ model_id ) { if ( $ object = $ this -> repository -> find ( $ model_id ) ) { $ object -> attachTags ( $ data [ 'tag_names' ] ) ; } } \ Cache :: tags ( 'response' ) -> flush ( ) ; return $ this -> successJsonResponse ( ) ; }
Mass Attach Tags
54,677
function getColumn ( $ c ) { if ( ! isset ( $ this -> columns [ $ c ] ) ) { throw new \ OutOfBoundsException ( "Unknown column $c" ) ; } return $ this -> columns [ $ c ] ; }
Get a single column
54,678
protected function getWel ( ) { if ( ! is_null ( $ this -> wel ) ) return $ this -> wel ; $ this -> app -> loadDeferredProviders ( ) ; $ this -> wel = ConsoleApplication :: make ( $ this -> app ) ; return $ this -> wel -> boot ( ) ; }
Get the Artisan console instance .
54,679
private function metaTag ( $ name , $ content ) { $ name = htmlspecialchars ( $ name ) ; $ content = htmlspecialchars ( $ content ) ; if ( substr ( $ name , 0 , 3 ) == 'og:' || substr ( $ name , 0 , 3 ) == 'fb:' ) { if ( $ name == 'og:image' ) { return "<meta property=\"$name\" content=\"$content&auto=format%2Ccompress\"/>" ; } if ( substr ( $ name , 0 , 8 ) == 'og:image' ) { return "<meta property=\"$name\" content=\"$content\"/>" ; } if ( substr ( $ name , 0 , 6 ) == 'og:url' ) { return "<meta itemprop=\"url\" property=\"$name\" content=\"$content\"/>" ; } return "<meta property=\"$name\" content=\"$content\"/>" ; } else if ( substr ( $ name , 0 , 11 ) == 'description' ) { return "<meta itemprop=\"description\" name=\"$name\" content=\"$content\"/>" ; } else if ( substr ( $ name , 0 , 7 ) == 'section' ) { return "<meta itemprop=\"articleSection\" name=\"$name\" content=\"$content\"/>" ; } else if ( substr ( $ name , 0 , 9 ) == 'image_src' ) { return "<meta itemprop=\"thumbnailUrl\" name=\"$name\" content=\"$content\"/>" ; } else if ( substr ( $ name , 0 , 4 ) == 'rel:' ) { $ name = ltrim ( $ name , "rel:" ) ; return "<link rel=\"$name\" href=\"$content\"/>" ; } else return "<meta name=\"$name\" content=\"$content\"/>" ; }
Returns a meta tag with the given name and content .
54,680
private function rotate ( ContextInterface $ context , array $ dependencies ) : array { if ( empty ( $ dependencies ) ) { return [ ] ; } $ top = array_shift ( $ dependencies ) ; $ variants = [ ] ; foreach ( $ top -> getVariants ( ) as $ value ) { $ variant = $ context -> withDependency ( new ValueDependency ( $ top -> getName ( ) , $ value ) ) ; if ( empty ( $ dependencies ) ) { $ variants [ ] = $ variant ; continue ; } foreach ( $ this -> rotate ( $ variant , $ dependencies ) as $ inner ) { $ variants [ ] = $ inner ; } } return $ variants ; }
Rotate all possible context values using recursive tree walk .
54,681
protected function _getStackEntry ( $ file_path , $ priority = null , $ is_minified = null ) { $ stack_entry = $ this -> _default_stack_entry ; if ( is_array ( $ file_path ) ) { $ stack_entry = array_merge ( $ stack_entry , $ file_path ) ; if ( isset ( $ stack_entry [ 'is_minified' ] ) ) { $ stack_entry [ 'minified' ] = $ stack_entry [ 'is_minified' ] ; unset ( $ stack_entry [ 'is_minified' ] ) ; } } else { $ stack_entry [ 'file' ] = $ file_path ; } if ( ! is_null ( $ priority ) ) { $ stack_entry [ 'priority' ] = $ priority ; } if ( ! is_null ( $ is_minified ) ) { $ stack_entry [ 'minified' ] = $ is_minified ; } if ( \ AssetsManager \ Loader :: isUrl ( $ stack_entry [ 'file' ] ) ) { $ stack_entry [ 'path' ] = $ stack_entry [ 'file' ] ; return $ stack_entry ; } $ _fp = $ this -> __template -> findAsset ( $ stack_entry [ 'file' ] ) ; if ( $ _fp ) { $ stack_entry [ 'path' ] = $ _fp ; return $ stack_entry ; } else { throw new TemplateEngineException ( sprintf ( 'Javascript file "%s" not found!' , $ file_path ) ) ; } }
Get a full formated stack entry
54,682
public function addIfExists ( $ file_path ) { $ _fp = $ this -> __template -> findAsset ( $ file_path ) ; if ( $ _fp || \ AssetsManager \ Loader :: isUrl ( $ file_path ) ) { return $ this -> add ( $ file_path ) ; } return $ this ; }
Add a javascript file in javascript stack
54,683
public function set ( array $ files ) { if ( ! empty ( $ files ) ) { foreach ( $ files as $ _file ) { $ this -> add ( $ _file ) ; } } return $ this ; }
Set a full javascript stack
54,684
public function writeMerged ( $ mask = '%s' ) { $ str = '' ; foreach ( $ this -> cleanStack ( $ this -> getMerged ( ) , 'path' ) as $ entry ) { $ tag_attrs = array ( 'type' => 'text/javascript' , 'src' => $ entry [ 'path' ] ) ; $ str .= sprintf ( $ mask , Html :: writeHtmlTag ( 'script' , null , $ tag_attrs ) ) ; } return $ str ; }
Write merged versions of the files stack in the cache directory
54,685
public function addMinified ( $ file_path ) { $ stack = $ this -> _getStackEntry ( $ file_path , null , true ) ; $ this -> registry -> addEntry ( $ stack , 'javascript_files' ) ; $ this -> registry -> addEntry ( $ stack , 'javascript_minified_files' ) ; return $ this ; }
Add an minified file
54,686
public function setMinified ( array $ files ) { if ( ! empty ( $ files ) ) { foreach ( $ files as $ _file ) { $ this -> addMinified ( $ _file ) ; } } return $ this ; }
Set a stack of minified files
54,687
public static function simple ( ) { return new static ( new DetailFactory ( new PhotoFactory ( ) ) , new CategoryFactory ( ) , new ContactFactory ( ) , new LocationFactory ( ) , new TipGroupFactory ( new TipFactory ( ) ) , new PhotoGroupFactory ( new PhotoFactory ( ) ) ) ; }
Convenience factory method creating a standard Venue factory configuration .
54,688
private function getCategories ( Description $ description ) { return array_map ( function ( \ stdClass $ categoryDescription ) { return $ this -> categoryFactory -> create ( new Description ( $ categoryDescription ) ) ; } , $ description -> getOptionalProperty ( 'categories' , [ ] ) ) ; }
Get the venue categories .
54,689
private function getTipGroups ( Description $ description ) { $ tipsDescription = $ description -> getOptionalProperty ( 'tips' ) ; if ( ! ( $ tipsDescription instanceof Description ) ) { return [ ] ; } return array_map ( function ( \ stdClass $ groupDescription ) { return $ this -> tipGroupFactory -> create ( new Description ( $ groupDescription ) ) ; } , $ tipsDescription -> getOptionalProperty ( 'groups' , [ ] ) ) ; }
Get the venue tip groups .
54,690
private function getPhotoGroups ( Description $ description ) { $ photosDescription = $ description -> getOptionalProperty ( 'photos' ) ; if ( ! ( $ photosDescription instanceof Description ) ) { return [ ] ; } return array_map ( function ( \ stdClass $ groupDescription ) { return $ this -> photoGroupFactory -> create ( new Description ( $ groupDescription ) ) ; } , $ photosDescription -> getOptionalProperty ( 'groups' , [ ] ) ) ; }
Get the photo groups .
54,691
public function generateProperties ( ) { $ attributes = $ this -> getAttributes ( ) ; $ properties = 'Class Properties:' . "\n" ; foreach ( $ attributes as $ name => $ attribute ) { $ properties .= '@property ' ; switch ( $ attribute [ 'type' ] ) { case 'self::TYPE_INT' : $ properties .= 'integer' ; break ; case 'self::TYPE_STRING' : $ properties .= 'string' ; break ; case 'self::TYPE_BOOL' : $ properties .= 'boolean' ; break ; case 'self::TYPE_DATE' : $ properties .= 'date' ; break ; case 'self::TYPE_DATETIME' : $ properties .= 'datetime' ; break ; case 'self::TYPE_DECIMAL' : $ properties .= 'float' ; break ; case 'self::TYPE_ENUM' : $ properties .= 'enum' ; break ; case 'self::TYPE_BINARY' : $ properties .= 'binary' ; break ; } $ properties .= ' $' . $ name . "\n" ; } if ( substr ( $ properties , - 1 ) == "\n" ) { $ properties = substr ( $ properties , 0 , - 1 ) ; } return $ properties ; }
Generate class properties comment
54,692
public function generateAttributes ( ) { $ attributes = $ this -> getAttributes ( ) ; $ this -> addLine ( 'protected static $attributes = array (' ) ; $ this -> tabUp ( FALSE ) ; foreach ( $ attributes as $ name => $ attribute ) { $ this -> addLine ( $ this -> tabVals ( '\'' . $ name . '\'' , 'array (' , 4 , '=> ' ) ) ; $ this -> tabUp ( FALSE ) ; foreach ( $ attribute as $ key => $ val ) { switch ( $ key ) { case 'charset' : case 'relation' : $ val = '\'' . $ val . '\'' ; break ; case 'valid' : case 'values' : $ val = 'array (' . $ val . ')' ; break ; } $ this -> addLine ( $ this -> tabVals ( '\'' . $ key . '\'' , $ val . ',' , 3 , '=> ' ) ) ; } if ( substr ( $ this -> class , - 2 ) == ",\n" ) { $ this -> class = substr ( $ this -> class , 0 , - 2 ) . "\n" ; } $ this -> tabDown ( FALSE ) ; $ this -> addLine ( '),' ) ; } if ( substr ( $ this -> class , - 2 ) == ",\n" ) { $ this -> class = substr ( $ this -> class , 0 , - 2 ) . "\n" ; } $ this -> tabDown ( FALSE ) ; $ this -> addLine ( ');' ) ; }
Generate class attribute array
54,693
public function getPk ( ) { if ( ! $ this -> get ( 'table' ) ) { return FALSE ; } $ db = new Db ; return $ db -> getPrimaryKey ( $ this -> get ( 'database' ) , $ this -> get ( 'table' ) ) ; }
Return class primary key
54,694
public function getAttributes ( ) { if ( $ this -> attributeCache === FALSE ) { $ this -> attributeCache = array ( ) ; if ( $ this -> get ( 'table' ) ) { $ db = new Db ; foreach ( $ db -> getColumns ( $ this -> get ( 'database' ) , $ this -> get ( 'table' ) ) as $ column ) { $ attribute = array ( 'get' => 'TRUE' , 'set' => 'TRUE' ) ; $ this -> attributeCache [ $ column [ 0 ] ] = array_merge ( $ attribute , $ db -> parseColumn ( $ column ) ) ; } $ this -> getRelations ( ) ; } } return $ this -> attributeCache ; }
Return class attributes
54,695
public function getRelations ( ) { $ db = new Db ; $ relations = $ db -> getRelations ( $ this -> get ( 'database' ) , $ this -> get ( 'table' ) ) ; $ namespace = $ this -> getRootNamespace ( ) ; foreach ( $ relations as $ constraint ) { if ( isset ( $ this -> attributeCache [ $ constraint [ 'attribute' ] ] ) ) { $ this -> attributeCache [ $ constraint [ 'attribute' ] ] [ 'relation' ] = $ this -> parser -> convertToClassName ( $ constraint [ 'table' ] , $ namespace ) ; } } }
Add attribute class relationships
54,696
public function getRootNamespace ( ) { $ arr = explode ( '\\' , $ this -> get ( 'namespace' ) ) ; $ table = explode ( '_' , $ this -> get ( 'table' ) ) ; $ ns = [ ] ; foreach ( $ arr as $ nsSegment ) { $ tableSegment = array_shift ( $ table ) ; if ( strtolower ( $ nsSegment ) != strtolower ( $ tableSegment ) ) { $ ns [ ] = $ nsSegment ; array_unshift ( $ table , $ tableSegment ) ; } } $ namespace = join ( '\\' , $ ns ) . '\\' ; return $ namespace ; }
Return root namespace
54,697
public function lineComment ( $ strComment ) { $ this -> class .= Comment :: lineComment ( $ strComment , $ this -> tabCount ) ; if ( $ this -> autoSpaces ) { $ this -> addLine ( ) ; } }
Add a line comment to the class
54,698
public function starComment ( $ strComment ) { $ this -> class .= Comment :: starComment ( $ strComment , $ this -> tabCount ) ; if ( $ this -> autoSpaces ) { $ this -> addLine ( ) ; } }
Add a star comment to the class
54,699
public function phpdocComment ( $ strComment ) { $ this -> class .= Comment :: phpdocComment ( $ strComment , $ this -> tabCount ) ; if ( $ this -> autoSpaces ) { $ this -> addLine ( ) ; } }
Add a PHPDoc comment to the class