idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
12,700
private function mergeProperty ( $ destinationObject , \ ReflectionProperty $ destinationProperty , $ sourceObject , \ ReflectionProperty $ sourceProperty , array $ defaultPropertyValues ) { $ sourceProperty -> setAccessible ( true ) ; $ destinationProperty -> setAccessible ( true ) ; $ destinationValue = $ destination...
Merges the two properties over eachother .
12,701
public function generateBody ( ) { $ contents = stream_get_contents ( $ this -> stream ) ; return chunk_split ( base64_encode ( $ contents ) , 76 , ezcMailTools :: lineBreak ( ) ) ; }
Returns the contents of the file with the correct encoding .
12,702
protected static function boot ( ) { parent :: boot ( ) ; static :: addGlobalScope ( new MailingScope ) ; static :: creating ( function ( $ node ) { if ( empty ( $ node -> published_at ) ) { $ node -> published_at = Carbon :: now ( ) ; } $ node -> fireNodeEvent ( 'creating' ) ; } ) ; static :: created ( function ( $ no...
Boot model events
12,703
public function propagateIdToSources ( $ save = true ) { foreach ( $ this -> translations as $ source ) { $ source -> setExtensionNodeId ( $ this -> getKey ( ) , $ save ) ; } }
Propagates self id to sources
12,704
public function validateCanHaveParentOfType ( ) { if ( is_null ( $ this -> parent ) ) { return ; } $ allowedNodeTypes = json_decode ( $ this -> parent -> getNodeType ( ) -> allowed_children ) ; if ( empty ( $ allowedNodeTypes ) || in_array ( $ this -> getNodeTypeKey ( ) , $ allowedNodeTypes ) ) { return ; } throw new I...
Validates parent type
12,705
public function getNodeType ( ) { $ bag = hierarchy_bag ( 'nodetype' ) ; if ( $ this -> relationLoaded ( 'nodeType' ) ) { $ nodeType = $ this -> getRelation ( 'nodeType' ) ; } elseif ( $ nodeType = $ bag -> getNodeType ( $ this -> getNodeTypeKey ( ) ) ) { $ this -> setRelation ( 'nodeType' , $ nodeType ) ; } else { $ n...
Getter for node type
12,706
public function getNodeTypeName ( ) { return $ this -> nodeTypeName ? : ( is_null ( $ this -> getNodeType ( ) ) ? null : $ this -> getNodeType ( ) -> getName ( ) ) ; }
Gets the node type name
12,707
public function setNodeTypeByKey ( $ id ) { $ nodeType = NodeType :: findOrFail ( $ id ) ; $ this -> nodeType ( ) -> associate ( $ nodeType ) ; $ this -> mailing = $ nodeType -> isTypeMailing ( ) ; }
Sets the node type by key and validates it
12,708
public function isTranslationAttribute ( $ key ) { if ( $ this -> isSpecialAttribute ( $ key ) ) { return false ; } return $ this -> _isTranslationAttribute ( $ key ) || ( is_null ( $ this -> getNodeTypeName ( ) ) ? false : $ this -> isSourceAttribute ( $ key ) ) ; }
Checks if key is a translation attribute
12,709
protected function isSourceAttribute ( $ key ) { $ modelName = source_model_name ( $ this -> getNodeTypeName ( ) , true ) ; return in_array ( $ key , call_user_func ( [ $ modelName , 'getSourceFields' ] ) ) ; }
Checks if a key is a node source attribute
12,710
public function getNewTranslation ( $ locale ) { $ nodeSource = NodeSource :: newWithType ( $ locale , $ this -> getNodeTypeName ( ) ) ; $ this -> translations -> add ( $ nodeSource ) ; return $ nodeSource ; }
Overloading default Translatable functionality for creating a new translation
12,711
public function translateOrFirst ( $ locale = null ) { $ translation = $ this -> translate ( $ locale , true ) ; if ( ! $ translation ) { $ translation = $ this -> translations -> first ( ) ; } return $ translation ; }
Get source or fallback to first found translation
12,712
protected function determineSortableKey ( $ key ) { if ( in_array ( $ key , $ this -> sortableColumns ) || $ this -> isTranslationAttribute ( $ key ) ) { return $ key ; } return $ this -> getDefaultSortableKey ( ) ; }
Determines the sortable key from the map
12,713
public function scopeSortedBySourceAttribute ( Builder $ query , $ attribute , $ direction = 'ASC' ) { return $ this -> orderQueryBySourceAttribute ( $ query , $ attribute , $ direction ) ; }
Sorts by source attribute
12,714
public function scopeWithName ( Builder $ query , $ name , $ locale = null ) { return $ this -> scopeWhereTranslation ( $ query , 'node_name' , $ name , $ locale ) ; }
Scope for selecting with name
12,715
public function scopeWithType ( Builder $ query , $ type ) { $ this -> setNodeTypeName ( $ type ) ; return $ this -> scopeWhereTranslation ( $ query , 'source_type' , $ type , null ) ; }
Scope for selecting with type
12,716
public function scopeFilteredByStatus ( Builder $ query , $ status = null ) { $ status = is_null ( $ status ) ? request ( 'f' , 'all' ) : $ status ; if ( in_array ( $ status , [ 'published' , 'withheld' , 'draft' , 'pending' , 'archived' , 'invisible' , 'locked' ] ) ) { $ query -> { $ status } ( ) ; } return $ query ; ...
Status filter scope
12,717
public function getOrderedChildren ( $ perPage = null ) { $ children = $ this -> children ( ) ; $ this -> determineChildrenSorting ( $ children ) ; return $ this -> determineChildrenPagination ( $ perPage , $ children ) ; }
Get ordered children
12,718
public function getPublishedOrderedChildren ( $ perPage = null ) { $ children = $ this -> children ( ) -> published ( ) ; $ this -> determineChildrenSorting ( $ children ) ; return $ this -> determineChildrenPagination ( $ perPage , $ children ) ; }
Returns all published children with parameter ordered
12,719
public function determineChildrenSorting ( HasMany $ children ) { if ( in_array ( $ this -> children_order , $ this -> translatedAttributes ) ) { $ children -> sortedBySourceAttribute ( $ this -> children_order , $ this -> children_order_direction ) ; } else { $ children -> orderBy ( $ this -> children_order , $ this -...
Determines the children sorting
12,720
public function determineChildrenPagination ( $ perPage , HasMany $ children ) { if ( $ perPage === false ) { return $ children ; } return is_null ( $ perPage ) ? $ children -> get ( ) : $ children -> paginate ( $ perPage ) ; }
Determines the pagination of children
12,721
public function getPositionOrderedChildren ( $ perPage = null ) { $ children = $ this -> children ( ) -> defaultOrder ( ) ; return $ this -> determineChildrenPagination ( $ perPage , $ children ) ; }
Returns all children ordered by position
12,722
public function getPublishedPositionOrderedChildren ( $ perPage = null ) { $ children = $ this -> children ( ) -> published ( ) -> defaultOrder ( ) ; return $ this -> determineChildrenPagination ( $ perPage , $ children ) ; }
Returns all published children position ordered
12,723
public function hasTranslatedChildren ( $ locale = null ) { foreach ( $ this -> getChildren ( ) as $ child ) { if ( $ child -> hasTranslation ( $ locale ) ) { return true ; } } return false ; }
Filters children by locale
12,724
public function deleteTranslation ( $ locale ) { if ( $ this -> hasTranslation ( $ locale ) ) { if ( $ deleted = $ this -> getTranslation ( $ locale ) -> delete ( ) ) { $ this -> load ( 'translations' ) ; return true ; } } return false ; }
Deletes a translation
12,725
public function isPublished ( ) { return ( $ this -> status >= Node :: PUBLISHED ) || ( $ this -> status >= Node :: PENDING && $ this -> published_at <= Carbon :: now ( ) ) ; }
Checks if the node is published
12,726
public function transformInto ( $ id ) { $ newType = NodeType :: find ( $ id ) ; if ( is_null ( $ newType ) ) { throw new \ RuntimeException ( 'Node type does not exist' ) ; } $ sourceAttributes = $ this -> parseSourceAttributes ( ) ; $ this -> flushSources ( ) ; $ this -> transformNodeType ( $ newType ) ; $ this -> re...
Transforms the node type with to given type
12,727
public function parseSourceAttributes ( ) { $ attributes = [ ] ; foreach ( $ this -> translations as $ translation ) { $ attributes [ $ translation -> locale ] = $ translation -> source -> toArray ( ) ; } return $ attributes ; }
Parses source attributes
12,728
protected function flushSources ( ) { foreach ( $ this -> translations as $ translation ) { $ translation -> source -> delete ( ) ; $ translation -> flushTemporarySource ( ) ; unset ( $ translation -> relations [ 'source' ] ) ; } }
Flushes the source attributes
12,729
protected function transformNodeType ( NodeType $ nodeType ) { $ this -> setNodeTypeByKey ( $ nodeType -> getKey ( ) ) ; foreach ( $ this -> translations as $ translation ) { $ translation -> source_type = $ nodeType -> getName ( ) ; } }
Transforms the node type
12,730
public function scopeMostVisited ( Builder $ query , $ limit = null ) { $ query -> select ( \ DB :: raw ( 'nodes.*, count(*) as `aggregate`' ) ) -> join ( 'node_site_view' , 'nodes.id' , '=' , 'node_site_view.node_id' ) -> groupBy ( 'nodes.id' ) -> orderBy ( 'aggregate' , 'desc' ) ; if ( $ limit ) { $ query -> limit ( ...
Most visited scope
12,731
public function scopeRecentlyEdited ( Builder $ query , $ limit = null ) { $ query -> orderBy ( 'updated_at' , 'desc' ) ; if ( $ limit ) { $ query -> limit ( $ limit ) ; } return $ query ; }
Recently edited scope
12,732
public function scopeRecentlyCreated ( Builder $ query , $ limit = null ) { $ query -> orderBy ( 'created_at' , 'desc' ) ; if ( $ limit ) { $ query -> limit ( $ limit ) ; } return $ query ; }
Recently created scope
12,733
public function getSiteURL ( $ locale = null ) { $ node = $ this ; $ uri = '' ; do { $ uri = '/' . $ node -> getTranslationAttribute ( 'node_name' , $ locale ) . $ uri ; $ node = is_null ( $ node -> parent_id ) ? null : node_bag ( $ node -> parent_id , false ) ; } while ( ! is_null ( $ node ) && $ node -> home != '1' )...
Gets the full url for node
12,734
public function getPreviewURL ( $ locale = null ) { $ token = app ( ) -> make ( TokenManager :: class ) -> makeNewToken ( 'preview_nodes' ) ; $ url = $ this -> getSiteURL ( $ locale ) ; return $ url . '?preview_nodes=' . $ token ; }
Returns the preview url
12,735
public function getDefaultEditUrl ( $ locale = null ) { $ parameters = [ $ this -> getKey ( ) , $ this -> translateOrFirst ( $ locale ) -> getKey ( ) ] ; if ( $ this -> hidesChildren ( ) ) { if ( $ this -> children_display_mode === 'tree' ) { $ parameters = current ( $ parameters ) ; } return route ( 'reactor.nodes.chi...
Determines the default edit link for node
12,736
public function getSearchable ( ) { if ( is_null ( $ this -> getNodeTypeName ( ) ) ) { return $ this -> searchable ; } $ modelName = source_model_name ( $ this -> getNodeTypeName ( ) , true ) ; return array_merge_recursive ( $ this -> searchable , call_user_func ( [ $ modelName , 'getSearchable' ] ) ) ; }
It returns the searchable
12,737
public function getMetaImage ( ) { $ metaImage = $ this -> getTranslationAttribute ( 'meta_image' ) ; if ( $ metaImage = get_nuclear_cover ( $ metaImage ) ) { return $ metaImage ; } if ( $ coverImage = $ this -> getCoverImage ( ) ) { return $ coverImage ; } return null ; }
Meta image getter
12,738
public function getCoverImage ( ) { if ( $ this -> coverImage ) { return $ this -> coverImage ; } $ modelName = source_model_name ( $ this -> getNodeTypeName ( ) , true ) ; $ mutatables = call_user_func ( [ $ modelName , 'getMutatables' ] ) ; foreach ( $ mutatables as $ mutatable => $ type ) { if ( $ type === 'gallery'...
Gets the cover image
12,739
public function setIn ( $ keys , $ value ) { $ lastKey = array_shift ( $ keys ) ; if ( count ( $ keys ) > 0 && ! isset ( $ this -> $ lastKey -> { $ keys [ 0 ] } ) ) { throw new \ RuntimeException ( sprintf ( "Key '%s->%s' does not exist." , $ lastKey , $ keys [ 0 ] ) ) ; } if ( count ( $ keys ) > 0 && $ this -> $ lastK...
set a value in a nested map
12,740
public function getId ( $ alias ) { if ( ! isset ( $ this -> aliases [ $ alias ] ) ) { return null ; } $ id = $ this -> aliases [ $ alias ] ; while ( isset ( $ this -> aliases [ $ id ] ) ) { $ id = $ this -> aliases [ $ id ] ; } return $ id ; }
Returns the identifier of the item which has the given alias
12,741
public function add ( $ alias , $ id ) { if ( isset ( $ this -> aliases [ $ alias ] ) ) { if ( $ this -> aliases [ $ alias ] === $ id ) { return $ this ; } throw new Exception \ AliasAlreadyExistsException ( sprintf ( 'The "%s" sting cannot be used as an alias for "%s" item' . ' because it is already used for "%s" item...
Registers an alias for the specified identifier
12,742
public function remove ( $ alias ) { $ id = $ this -> getId ( $ alias ) ; if ( $ id ) { unset ( $ this -> aliases [ $ alias ] ) ; $ aliases = & $ this -> ids [ $ id ] ; unset ( $ aliases [ array_search ( $ alias , $ aliases , true ) ] ) ; if ( ! empty ( $ aliases ) ) { $ this -> removeDependedAliases ( $ alias , $ id )...
Removes the alias
12,743
public function removeById ( $ id ) { if ( isset ( $ this -> ids [ $ id ] ) ) { foreach ( $ this -> ids [ $ id ] as $ alias ) { unset ( $ this -> aliases [ $ alias ] ) ; } unset ( $ this -> ids [ $ id ] ) ; } return $ this ; }
Removes all aliases for the specified item
12,744
protected function removeDependedAliases ( $ alias , $ id ) { foreach ( $ this -> ids [ $ id ] as $ otherAlias ) { if ( isset ( $ this -> aliases [ $ otherAlias ] ) && $ this -> aliases [ $ otherAlias ] === $ alias ) { unset ( $ this -> aliases [ $ otherAlias ] ) ; $ aliases = & $ this -> ids [ $ id ] ; unset ( $ alias...
Removes all depended aliases For example if alias3 is removed in alias chain like alias1 - > alias2 - > alias3 - > id than both alias1 and alias2 are removed as well
12,745
public function getRootDirectory ( ) { $ config = $ this -> composer -> getConfig ( ) ; return str_replace ( $ config -> get ( 'vendor-dir' , Config :: RELATIVE_PATHS ) , '' , $ config -> get ( 'vendor-dir' ) ) ; }
Get the root directory .
12,746
public function getPublicDirectory ( ) { if ( isset ( $ this -> publicDirectory ) ) { return $ this -> publicDirectory ; } $ rootPkg = $ this -> composer -> getPackage ( ) ; if ( $ rootPkg ) { $ extra = $ rootPkg -> getExtra ( ) ; if ( $ extra && ! empty ( $ extra [ 'public-dir' ] ) ) { return $ this -> publicDirectory...
Get the public directory .
12,747
public function removeDirectoryPhp ( $ directory ) { $ it = new RecursiveDirectoryIterator ( $ directory , RecursiveDirectoryIterator :: SKIP_DOTS ) ; $ ri = new RecursiveIteratorIterator ( $ it , RecursiveIteratorIterator :: CHILD_FIRST ) ; foreach ( $ ri as $ file ) { if ( $ file -> isDir ( ) ) { $ this -> rmdir ( $ ...
Recursively delete directory using PHP iterators .
12,748
protected function transformException ( Exception $ exception ) { if ( Request :: capture ( ) -> wantsJson ( ) ) { $ this -> transformAuthException ( $ exception ) ; $ this -> transformEloquentException ( $ exception ) ; $ this -> transformValidationException ( $ exception ) ; } }
Transform a Laravel exception into an API exception .
12,749
protected function renderApiError ( ApiException $ exception ) : JsonResponse { return app ( 'responder.error' ) -> setError ( $ exception -> getErrorCode ( ) , $ exception -> getMessage ( ) ) -> addData ( $ exception -> getData ( ) ? : [ ] ) -> respond ( $ exception -> getStatusCode ( ) ) ; }
Renders any API exception into a JSON error response .
12,750
private static function getHTMLBackTrace ( $ backtrace ) { $ str = '' ; foreach ( $ backtrace as $ step ) { if ( $ step [ 'function' ] != 'getHTMLBackTrace' && $ step [ 'function' ] != 'handle_error' ) { $ str .= '<tr><td style="border-bottom: 1px solid #EEEEEE">' ; $ str .= ( ( isset ( $ step [ 'class' ] ) ) ? htmlspe...
Returns the Exception Backtrace as a nice HTML view .
12,751
private static function getPhpVariableAsText ( $ var ) { if ( is_string ( $ var ) ) { return ( '"' . str_replace ( array ( "\x00" , "\x0a" , "\x0d" , "\x1a" , "\x09" ) , array ( '\0' , '\n' , '\r' , '\Z' , '\t' ) , $ var ) . '"' ) ; } elseif ( is_int ( $ var ) || is_float ( $ var ) ) { return ( $ var ) ; } elseif ( is_...
Used by the debug function to display a nice view of the parameters .
12,752
private static function getRelativePath ( $ from , $ to ) { $ from = explode ( '/' , $ from ) ; $ to = explode ( '/' , $ to ) ; $ relPath = $ to ; foreach ( $ from as $ depth => $ dir ) { if ( isset ( $ to [ $ depth ] ) && $ dir === $ to [ $ depth ] ) { array_shift ( $ relPath ) ; } else { $ remaining = count ( $ from ...
Returns a relative path based on 2 absolute paths .
12,753
public function get ( $ category , $ key = null , $ default = null ) { $ this -> load ( $ category ) ; if ( $ key === null ) { return isset ( $ this -> items [ $ category ] ) && ! empty ( $ this -> items [ $ category ] ) ? $ this -> items [ $ category ] : $ default ; } if ( is_string ( $ key ) ) { return isset ( $ this...
Returns settings .
12,754
public function load ( $ categories ) { if ( is_string ( $ categories ) ) { $ categories = [ $ categories ] ; } foreach ( $ categories as $ idx => $ category ) { if ( isset ( $ this -> items [ $ category ] ) ) { unset ( $ categories [ $ idx ] ) ; } else { $ this -> items [ $ category ] = [ ] ; } } if ( empty ( $ catego...
Loads settings from category or multiple categories
12,755
protected function dbInsert ( $ category , $ key , $ value ) { $ created_by = \ Yii :: $ app -> user -> getId ( ) ; $ this -> getDb ( ) -> createCommand ( ' INSERT INTO {{setting}} (`category`, `key`, `value`, `created_at`, `created_by`) VALUES (:category, :key, :value, NOW(), :creat...
Stores settings in database
12,756
protected function dbUpdate ( $ category , $ key , $ value ) { $ updated_by = \ Yii :: $ app -> user -> getId ( ) ; $ this -> getDb ( ) -> createCommand ( ' UPDATE {{setting}} SET `value` = :value, `updated_at` = NOW(), `updated_by` = :up...
Updates setting in database
12,757
protected function dbDelete ( $ category , $ key = null ) { if ( $ key === null ) { $ this -> getDb ( ) -> createCommand ( ' DELETE FROM {{setting}} WHERE `category` = :category ' , compact ( 'category' ) ) -> execute ( ) ; } if ( is_string ...
Deletes setting from database
12,758
public function push ( $ type , $ name , $ value ) { $ typeModel = NotificationTypes :: where ( 'name' , $ type ) -> first ( ) ; if ( is_null ( $ typeModel ) ) { return false ; } $ tId = $ typeModel -> id ; $ model = $ this -> makeModel ( ) -> getModel ( ) -> newInstance ( [ 'type_id' => $ tId , 'name' => $ name , 'val...
push notification to database
12,759
public function findAllNew ( $ ids = [ ] ) { $ query = $ model = $ this -> makeModel ( ) -> where ( 'broadcasted' , 0 ) ; if ( ! empty ( $ ids ) ) { $ values = array_values ( $ ids ) ; $ query -> whereNotIn ( 'id' , $ values ) ; } return $ query -> get ( ) ; }
finds all new notification messages
12,760
public function query ( ) { $ read = NotificationsStackRead :: select ( [ 'stack_id' ] ) -> withTrashed ( ) -> where ( 'user_id' , user ( ) -> id ) -> whereNotNull ( 'deleted_at' ) -> pluck ( 'stack_id' ) ; return $ this -> makeModel ( ) -> newQuery ( ) -> distinct ( ) -> select ( [ 'tbl_notifications_stack.*' ] ) -> w...
Gets base query builder for notifications and alerts
12,761
protected function count ( $ builder ) { $ read = NotificationsStackRead :: select ( [ 'stack_id' ] ) -> withTrashed ( ) -> where ( 'user_id' , user ( ) -> id ) -> pluck ( 'stack_id' ) ; return $ builder -> whereNotIn ( 'id' , $ read ) -> count ( ) ; }
Assign counter query
12,762
public function clear ( $ type = 'notifications' ) { $ builder = ( $ type === 'alerts' ) ? $ this -> getAlerts ( ) : $ this -> getNotifications ( ) ; return $ this -> makeModel ( ) -> getModel ( ) -> read ( ) -> getModel ( ) -> newQuery ( ) -> whereIn ( 'stack_id' , $ builder -> pluck ( 'id' ) ) -> delete ( ) ; }
Deletes all messages
12,763
public function markAsRead ( $ type = 'notifications' ) { DB :: beginTransaction ( ) ; try { $ builder = ( $ type === 'alerts' ) ? $ this -> getAlerts ( ) : $ this -> getNotifications ( ) ; $ read = NotificationsStackRead :: select ( [ 'stack_id' ] ) -> withTrashed ( ) -> where ( 'user_id' , user ( ) -> id ) -> pluck (...
Mark notifications or alerts as read
12,764
public function deleteById ( $ id ) { $ read = NotificationsStackRead :: where ( [ 'stack_id' => $ id , 'user_id' => user ( ) -> id ] ) -> first ( ) ; if ( ! is_null ( $ read ) ) { return $ read -> delete ( ) ; } return false ; }
Deletes item by id
12,765
protected function resolveJsonCastableColumns ( & $ log ) { foreach ( $ log as $ name => $ value ) { if ( ! is_array ( $ value ) ) { continue ; } $ log [ $ name ] = json_encode ( $ value ) ; } return $ log ; }
Resolves json castable columns
12,766
public function fetchOne ( int $ id ) : Builder { return $ this -> makeModel ( ) -> newQuery ( ) -> withoutGlobalScopes ( ) -> distinct ( ) -> select ( [ 'tbl_notifications_stack.*' ] ) -> with ( 'content' ) -> with ( 'content.lang' ) -> with ( 'notification.type' ) -> where ( function ( $ query ) { $ query -> whereNul...
Fetch one stack item
12,767
public function load ( $ file , $ extension = 'json' ) { $ this -> file = $ file ; $ this -> extension = $ extension ; return $ this ; }
Load the file details
12,768
public function extract ( ) { $ this -> reader -> read ( $ this -> file ) ; $ this -> converter -> setExtension ( $ this -> extension ) -> process ( $ this -> reader -> getData ( ) ) ; }
Extracts the raw data from the file for conversion
12,769
protected function resolveOrder ( $ column , $ key ) { $ this -> resolve ( $ column , $ key , $ this -> getTableName ( ) , function ( $ query , $ pattern ) { $ this -> builder -> orderBy ( $ query , $ pattern ) ; } ) ; }
Recursively build up the order query .
12,770
public static function add ( string $ asset_type , string $ asset , string $ namespace , int $ priority = 1 ) : void { Assets :: $ assets [ $ namespace ] [ $ asset_type ] [ $ priority ] [ ] = [ 'asset' => $ asset ] ; }
Add new asset
12,771
public static function get ( string $ asset_type , string $ namespace ) : array { $ assets = [ ] ; if ( isset ( Assets :: $ assets [ $ namespace ] ) && isset ( Assets :: $ assets [ $ namespace ] [ $ asset_type ] ) && count ( Assets :: $ assets [ $ namespace ] [ $ asset_type ] ) > 0 ) { $ assets = Assets :: $ assets [ $...
Get assets for current namespace and asset type
12,772
protected function getSpecification ( $ file , $ settings , $ artifact ) { return fphp \ Specification \ TemplateSpecification :: fromArrayAndSettings ( $ file , $ settings , $ artifact ) ; }
Returns a template specification from a plain settings array .
12,773
public function actionIndex ( $ caller ) { $ model = new $ this -> modelClass ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { $ model = new $ this -> modelClass ( ) ; } if ( Yii :: $ app -> request -> post ( 'hasEditable' ) ) { $ this -> _update ( ) ; return ; } $ searchMod...
Single interface for all CRUD Operations .
12,774
public function actionDelete ( $ caller , $ id ) { $ this -> findModel ( $ id ) -> delete ( ) ; return $ this -> redirect ( [ 'index' , 'caller' => $ caller ] ) ; }
Deletes an existing ArtifactType model . If deletion is successful the browser will be redirected to the index page .
12,775
protected function findModel ( $ id ) { $ class = $ this -> modelClass ; if ( ( $ model = $ class :: findOne ( $ id ) ) !== null ) { return $ model ; } else { throw new NotFoundHttpException ( 'The requested page does not exist.' ) ; } }
Finds the ArtifactType model based on its primary key value . If the model is not found a 404 HTTP exception will be thrown .
12,776
public function getColumnDefinition ( ColumnInterface $ column ) { $ sql = parent :: getColumnDefinition ( $ column ) ; if ( $ column instanceof Column && $ column -> getComment ( ) ) { $ sql .= " COMMENT \"" . addcslashes ( $ column -> getComment ( ) , '"' ) . "\"" ; } $ def = $ column -> getDefault ( ) ; if ( isset (...
supports comment and tinyint
12,777
public function addBreadcrumbs ( array $ breadcrumbs = [ ] ) { foreach ( $ breadcrumbs as $ breadcrumb ) { $ this -> addCrumb ( isset ( $ breadcrumb [ 'name' ] ) ? $ breadcrumb [ 'name' ] : '' , isset ( $ breadcrumb [ 'href' ] ) ? $ breadcrumb [ 'href' ] : '' ) ; } return $ this ; }
Add the breadcrumbs to the current list .
12,778
public function addCrumb ( string $ name = '' , string $ href = '' ) : Breadcrumbs { $ breadcrumb = [ 'name' => $ name , 'href' => $ href ] ; if ( ! $ this -> validateCrumb ( $ breadcrumb ) ) { throw new InvalidArgumentException ( 'Breadcrumbs::addCrumb() only accepts correctly formatted arrays.' ) ; } $ crumb = [ 'nam...
Add a crumb to the internal array .
12,779
public function firstFormated ( ) : string { if ( $ this -> isEmpty ( ) ) { return '' ; } $ crumb = reset ( $ this -> breadcrumbs ) ; return $ this -> renderCrumb ( $ crumb [ 'name' ] , $ crumb [ 'href' ] , false , 1 ) ; }
Get the first crumb formated as HTML .
12,780
public function lastFormated ( ) : string { if ( $ this -> isEmpty ( ) ) { return '' ; } $ crumb = end ( $ this -> breadcrumbs ) ; return $ this -> renderCrumb ( $ crumb [ 'name' ] , $ crumb [ 'href' ] , false , 1 ) ; }
Get the last crumb formated as HTML .
12,781
protected function renderCrumb ( $ name , $ href , $ isLast = false , $ position = null ) : string { $ positionAttribute = '' ; if ( $ this -> getOption ( 'position' ) ) { $ positionAttribute = "data-position=\"{$position}\"" ; } if ( $ isLast ) { $ element = $ this -> getOption ( 'listActiveElement' ) ; $ classes = $ ...
Render a crumb .
12,782
protected function getClasses ( string $ option , string $ separator = ' ' ) : string { return implode ( $ separator , $ this -> getOption ( $ option ) ) ; }
Get the imploded classes for the given option .
12,783
protected function renderCrumbs ( ) : string { end ( $ this -> breadcrumbs ) ; $ lastKey = key ( $ this -> breadcrumbs ) ; $ output = '' ; $ position = 1 ; foreach ( $ this -> breadcrumbs as $ key => $ crumb ) { $ isLast = ( $ lastKey === $ key ) ; $ href = $ crumb [ 'href' ] ; if ( ! preg_match ( '#^https?://.*#' , $ ...
Renders the crumbs .
12,784
public function render ( ) : string { if ( empty ( $ this -> breadcrumbs ) ) { return '' ; } $ classes = $ this -> getClasses ( 'listElementClasses' ) ; $ element = $ this -> getOption ( 'listElement' ) ; return "<{$element} class=\"{$classes}\">" . $ this -> renderCrumbs ( ) . "</{$element}>" ; }
Renders the complete breadcrumbs into HTML .
12,785
public function set ( $ name , $ value ) { $ this -> data [ $ this -> normalizeKey ( $ name ) ] = $ value ; return $ this ; }
Set a HTTP header .
12,786
protected function normalizeKey ( $ name ) { $ name = strtolower ( $ name ) ; $ name = str_replace ( array ( '-' , '_' ) , ' ' , $ name ) ; $ name = preg_replace ( '#^http #' , '' , $ name ) ; $ name = ucwords ( $ name ) ; $ name = str_replace ( ' ' , '-' , $ name ) ; return $ name ; }
Normalize HTTP header name .
12,787
public function evaluate ( ) { $ httpRequest = Request :: createFromEnvironment ( ) ; $ mode = $ this -> interfaceRenderModeService -> findModeByCurrentUser ( ) ; $ renderMode = 0 ; switch ( true ) { case $ mode -> getName ( ) === 'wireframe' || $ httpRequest -> getArgument ( 'wireframeMode' ) == '1' : $ renderMode = 1...
Evaluate wireframe rendering mode
12,788
public function setServiceLocator ( ServiceLocatorInterface $ serviceManager ) { if ( ! $ this -> dbAdapter instanceof DbAdapter ) { $ this -> dbAdapter = $ serviceManager -> getServiceLocator ( ) -> get ( $ this -> dbAdapter ) ; } }
Use Service Manager to inject database adapter
12,789
public function getCleanInterval ( ) { if ( ! $ this -> cleanInterval instanceof DateInterval ) { $ this -> cleanInterval = new DateInterval ( $ this -> cleanInterval ) ; } return $ this -> cleanInterval ; }
Get clean interval
12,790
public function increment ( $ ip , $ type ) { $ this -> assertReady ( ) ; $ sql = sprintf ( "INSERT INTO %s SET %s=:type, %s=:ip" , $ this -> dbAdapter -> platform -> quoteIdentifier ( $ this -> table ) , $ this -> dbAdapter -> platform -> quoteIdentifier ( $ this -> typeColumn ) , $ this -> dbAdapter -> platform -> qu...
Add record to database
12,791
public function check ( $ ip , Limit $ limit ) { $ this -> assertReady ( ) ; if ( $ this -> cleanOnCheck ) { $ this -> clean ( ) ; } $ sql = sprintf ( "SELECT count(*) as count FROM %s WHERE %s=:ip AND %s=:type AND %s >= NOW() - INTERVAL %d SECOND" , $ this -> dbAdapter -> platform -> quoteIdentifier ( $ this -> table ...
Check if the number or records in the database exceeds the set limit
12,792
public function clean ( ) { $ this -> assertReady ( ) ; $ sql = sprintf ( "DELETE FROM %s WHERE %s < NOW() - INTERVAL %d SECOND" , $ this -> dbAdapter -> platform -> quoteIdentifier ( $ this -> table ) , $ this -> dbAdapter -> platform -> quoteIdentifier ( $ this -> timestampColumn ) , $ this -> getCleanInterval ( ) ->...
Remove expired records from database
12,793
public function register ( $ alias , $ class ) { $ alias = strtolower ( $ alias ) ; if ( array_key_exists ( $ alias , $ this -> instances ) ) { throw new \ RuntimeException ( 'You cannot register a provider when an instance of that class has already been created.' ) ; } $ this -> services [ $ alias ] = $ class ; return...
Registers a specific class name with the corresponding alias for the dependency inversion .
12,794
public function unregister ( $ alias , $ remove_instances = false ) { $ alias = strtolower ( $ alias ) ; if ( $ remove_instances && array_key_exists ( $ alias , $ this -> instances ) ) { $ this -> instances [ $ alias ] = null ; unset ( $ this -> instances [ $ alias ] ) ; } unset ( $ this -> services [ $ alias ] ) ; ret...
Unregisters a single service provider . If an instance of that provider has already been created it will be destroyed .
12,795
public function saveInstance ( $ alias , & $ class ) { $ alias = strtolower ( $ alias ) ; if ( array_key_exists ( $ alias , $ this -> instances ) ) { unset ( $ this -> instances [ $ alias ] ) ; } $ this -> instances [ $ alias ] = $ class ; return $ this ; }
Registers an instantiated class as a Service Provider .
12,796
public function single ( $ alias ) { $ alias = strtolower ( $ alias ) ; if ( ! empty ( $ this -> instances [ $ alias ] ) && is_object ( $ this -> instances [ $ alias ] ) ) { return $ this -> instances [ $ alias ] ; } if ( empty ( $ this -> services [ $ alias ] ) ) { throw new \ InvalidArgumentException ( 'Unable to fin...
Allows you to create a new instance of an object as a singleton passing in arguments .
12,797
protected function getParams ( \ ReflectionMethod $ mirror , $ single = false ) { $ params = [ ] ; foreach ( $ mirror -> getParameters ( ) as $ param ) { $ alias = strtolower ( $ param -> name ) ; if ( ! empty ( $ this -> services [ $ alias ] ) ) { $ params [ ] = $ single ? $ this -> single ( $ alias ) : $ this -> make...
Given a reflection method will get or create an array of objects ready to be inserted into the class constructor .
12,798
public function compile ( $ source , $ destination = null , $ include = null ) { $ include = array_merge ( $ this -> includes , ( array ) $ include ) ; $ useCache = null == $ destination && null !== $ this -> cache ; if ( $ useCache ) { if ( $ this -> cache -> hasItem ( $ source ) ) { return $ this -> cache -> getItem ...
Compile to file . If destination is not specified return CSS .
12,799
public function setCache ( $ cache ) { if ( is_string ( $ cache ) && class_exists ( $ cache ) ) { $ cache = new $ cache ( ) ; } if ( is_array ( $ cache ) ) { $ cache = StorageFactory :: factory ( $ cache ) ; } if ( ! $ cache instanceof AbstractCacheAdapter ) { throw new \ Exception ( 'Invalid Cache' ) ; } $ this -> cac...
Set cache for CSS Preprocessor