idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
8,600
public function setDescription ( $ objectData , $ customData = [ ] ) { $ this -> set ( 'description' , $ customData [ 'description' ] ) ; if ( isset ( $ customData [ 'description' ] ) ) { $ this -> set ( 'description' , $ customData [ 'description' ] ) ; } else { if ( ! $ this -> metaExists ( 'description' ) && isset (...
Set meta description
8,601
public function setProfileOG ( $ profileObj ) { Meta :: set ( "profile:first_name" , $ profileObj -> firstName , "property" ) ; Meta :: set ( "profile:last_name" , $ profileObj -> lastName , "property" ) ; if ( isset ( $ profileObj -> gender ) ) { Meta :: set ( "profile:gender" , $ profileObj -> gender , "property" ) ;...
Set profile open graph
8,602
public function setArticleOG ( $ postObj ) { Meta :: set ( "article:published_time" , $ postObj -> created_at -> format ( 'c' ) , "propery" ) ; Meta :: set ( "article:modified_time" , $ postObj -> updated_at -> format ( 'c' ) , "propery" ) ; if ( $ postObj -> user ) { Meta :: set ( "article:author" , $ postObj -> user ...
Set article open graph
8,603
public function setImageOG ( $ imageObj ) { if ( $ imageObj ) { Meta :: set ( "og:image" , asset ( $ imageObj -> url ) , "property" ) ; Meta :: set ( "og:image:type" , $ imageObj -> type . "/" . str_replace ( "jpg" , "jpeg" , $ imageObj -> extension ) , "property" ) ; if ( $ imageObj -> description ) { Meta :: set ( "o...
Set image open graph
8,604
public function printMetaTags ( ) { if ( ! $ this -> getMetaIsPrinted ( ) ) { $ this -> printTitle ( ) ; $ this -> printMetaTagsList ( ) ; $ this -> printCanonical ( ) ; $ this -> printHrefLang ( ) ; $ this -> setMetaIsPrinted ( ) ; } return $ this ; }
Print meta html
8,605
private function printMetaTagsList ( ) { foreach ( $ this -> metaList as $ metaName => $ metaData ) { if ( in_array ( $ metaName , $ this -> allowedDuplicateMeta ) ) { foreach ( $ metaData as $ duplicateMetaData ) { print '<meta ' . $ duplicateMetaData [ 'type' ] . '="' . $ metaName . '" content="' . $ duplicateMetaDat...
Print meta tags list
8,606
public function parseAttributes ( $ attributes ) { if ( $ attributes ) { $ htmlMeta = ' ' ; foreach ( $ attributes as $ key => $ value ) { if ( $ key == 'async' && $ value == false ) { continue ; } if ( $ value === false ) { $ value = 'false' ; } else if ( $ value === true ) { $ value = 'true' ; } $ htmlMeta .= $ key ....
Parse a list of array as meta tags
8,607
public function validateWildCards ( $ input , $ errorClass = '' ) { preg_match_all ( '@\{.*?\}}@' , $ input , $ matches ) ; $ notDefined = [ ] ; if ( $ matches ) { foreach ( $ matches as $ match ) { foreach ( $ match as $ wildcard ) { if ( ! array_key_exists ( $ wildcard , $ this -> getWildcards ( ) ) ) { $ notDefined ...
Check if there is any undefined wildcard
8,608
public function setHrefLang ( $ url , $ hreflang ) { if ( $ url && $ hreflang ) { $ this -> hreflang [ ] = [ 'url' => $ url , 'lang' => $ hreflang ] ; } return $ this ; }
Set href lang alternate list
8,609
public function setHrefLangData ( $ model , $ routeName = '' ) { foreach ( Language :: getVisibleList ( ) as $ language ) { Meta :: setHrefLang ( $ model -> translate ( $ language -> slug ) -> href ( $ routeName ) , $ language -> slug ) ; } return $ this ; }
Set href lang data
8,610
public static function get ( $ arr , $ str_path , $ default = null ) { $ path = explode ( '.' , $ str_path ) ; return static :: array_get ( $ arr , $ path , $ default ) ; }
Get element from array with a path .
8,611
public static function set ( & $ arr , $ str_path , $ value ) { $ path = explode ( '.' , $ str_path ) ; static :: array_set ( $ arr , $ path , $ value ) ; }
Set element in array with a path .
8,612
public static function append ( & $ arr , $ str_path , $ value ) { $ path = explode ( '.' , $ str_path ) ; static :: array_append ( $ arr , $ path , $ value ) ; }
Add element in array with a path .
8,613
public static function array_append ( & $ arr , $ path , $ value ) { if ( ! is_array ( $ path ) ) $ path = [ $ path ] ; $ lastkey = array_pop ( $ path ) ; foreach ( $ path as $ parent ) $ arr = & $ arr [ $ parent ] ; $ arr [ $ lastkey ] [ ] = $ value ; }
Add element in array .
8,614
public static function array_get ( $ arr , $ path , $ default = null ) { if ( ! is_array ( $ path ) ) $ path = [ $ path ] ; foreach ( $ path as $ key ) { if ( ! isset ( $ arr [ $ key ] ) ) return $ default ; else $ arr = $ arr [ $ key ] ; } return $ arr ; }
Get element in array .
8,615
public static function array_has ( $ arr , $ path ) { if ( ! $ path ) return false ; if ( ! is_array ( $ path ) ) $ path = [ $ path ] ; foreach ( $ path as $ key ) { if ( ! isset ( $ arr [ $ key ] ) ) return false ; else $ arr = $ arr [ $ key ] ; } return true ; }
Check if element exists in array .
8,616
public static function array_delete ( & $ arr , $ path ) { if ( ! $ path ) return ; if ( ! is_array ( $ path ) ) $ path = [ $ path ] ; $ lastkey = array_pop ( $ path ) ; foreach ( $ path as $ parent ) $ arr = & $ arr [ $ parent ] ; unset ( $ arr [ $ lastkey ] ) ; }
Unset element in array .
8,617
public static function before ( $ arr , $ i ) { $ res = [ ] ; foreach ( $ arr as $ k => $ v ) { if ( $ k === $ i ) return $ res ; $ res [ $ k ] = $ v ; } return $ res ; }
Return all ements before a given position .
8,618
public static function after ( $ arr , $ i ) { $ res = [ ] ; $ do = false ; foreach ( $ arr as $ k => $ v ) { if ( $ do ) $ res [ $ k ] = $ v ; if ( $ k === $ i ) $ do = true ; } return $ res ; }
Return all ements after a given position .
8,619
private function canUpdate ( ) { $ this -> info ( "Validating" ) ; if ( ! file_exists ( pluginsPath ( $ this -> pluginNamespace ) ) ) { throw new \ Exception ( "Plugin " . $ this -> pluginNamespace . " not found in plugins directory!" ) ; } if ( ! Plugin :: where ( 'namespace' , $ this -> pluginNamespace ) -> first ( )...
Checks if a plugin can be updated
8,620
public function GetCommunity ( string $ community = NULL ) { $ result = $ this -> ExecuteCall ( "GetCommunity" , ( object ) [ "community" => $ community ] , GnResponseType :: GnCommunity ) ; return $ result ; }
Get the community details .
8,621
public function InviteMemberToCommunity ( string $ toLoginName , string $ community = NULL ) { $ this -> ExecuteCall ( "InviteMemberToCommunity" , ( object ) [ "community" => $ community , "toLoginName" => $ toLoginName ] , GnResponseType :: Json , FALSE , PHP_INT_MAX ) ; }
Sends a nose - mail invitation to a new community member .
8,622
public function load ( $ ident ) { if ( substr ( $ ident , 0 , 1 ) === '$' ) { $ tryLegacy = ( $ ident === '$widget_template' ) ; $ ident = $ this -> dynamicTemplate ( substr ( $ ident , 1 ) ) ; if ( $ tryLegacy ) { $ ident = empty ( $ GLOBALS [ 'widget_template' ] ) ? $ ident : $ GLOBALS [ 'widget_template' ] ; $ this...
Load a template content
8,623
public function menuPanelItems ( $ lang = "" ) { if ( ! User :: hasAccess ( 'PostType' , 'read' ) ) { return $ this -> noPermission ( ) ; } $ categoryObj = Category :: visible ( ) ; if ( Input :: input ( 'keyword' ) ) { $ categoryObj -> where ( 'title' , 'like' , '%' . Input :: input ( 'keyword' ) . '%' ) ; } $ categor...
Get categories to be displayed in menu panel .
8,624
public function getTree ( $ lang = "" , $ postTypeID ) { $ orderBy = ( isset ( $ _GET [ 'order' ] ) ) ? $ orderBy = $ _GET [ 'order' ] : 'order' ; $ orderType = ( isset ( $ _GET [ 'type' ] ) ) ? $ orderType = $ _GET [ 'type' ] : 'ASC' ; $ parentList = Category :: where ( 'postTypeID' , $ postTypeID ) -> where ( 'parent...
Gets categories by post type with parent child relations .
8,625
public function delete ( $ lang , $ id ) { if ( ! User :: hasAccess ( 'Categories' , 'delete' ) ) { return $ this -> noPermission ( ) ; } $ categoryDeleteRes = $ this -> deleteCategory ( $ id ) ; if ( gettype ( $ categoryDeleteRes ) == "boolean" ) { if ( $ categoryDeleteRes ) { return $ this -> response ( 'Category cou...
Delete a Category and his children .
8,626
public function bulkDelete ( Request $ request ) { if ( ! User :: hasAccess ( 'Categories' , 'delete' ) ) { return $ this -> noPermission ( ) ; } if ( count ( $ request -> all ( ) ) <= 0 ) { return $ this -> response ( 'Please select items to be deleted' , 500 ) ; } foreach ( $ request -> all ( ) as $ id ) { $ category...
Bulk Delete categories Delete many categories in one request .
8,627
private function deleteCategory ( int $ id ) { $ category = Category :: find ( $ id ) ; if ( $ category ) { $ postType = PostType :: findByID ( $ category -> postTypeID ) ; if ( Category :: isInMenuLinks ( $ id ) ) { return $ this -> response ( "You can't delete this Category. It is part of a menu" , 403 ) ; } $ catego...
Delete single category and all its children .
8,628
public function store ( Request $ request ) { if ( ! User :: hasAccess ( 'Categories' , 'create' ) ) { return $ this -> noPermission ( ) ; } $ data = $ request -> all ( ) ; $ structuredData = $ this -> generateTitleAndSlug ( $ data [ 'form' ] ) ; $ form = $ structuredData [ 'form' ] ; $ errors = $ structuredData [ 'err...
Save Category in database .
8,629
private function generateTitleAndSlug ( $ form ) { $ errors = [ ] ; $ requiredMessage = " is required" ; $ defaultLanguage = Language :: getDefault ( ) ; $ result = $ form ; $ defaultLanguageTitle = '' ; if ( isset ( $ form [ 'title' ] ) && isset ( $ form [ 'title' ] [ $ defaultLanguage -> slug ] ) && $ form [ 'title' ...
If title and slug are empty fill them with the default language title .
8,630
private function redirect ( string $ redirect , int $ categoryID , int $ postTypeID ) { $ adminPrefix = Config :: get ( 'project' ) [ 'adminPrefix' ] ; if ( $ redirect == 'save' ) { $ redirectUrl = "/" . $ adminPrefix . "/" . App :: getLocale ( ) . "/post-type/categoryupdate/" . $ categoryID ; $ view = 'categoryupdate'...
Redirect parameters used in frontend .
8,631
public function detailsJSON ( $ lang , $ id ) { if ( ! User :: hasAccess ( 'Categories' , 'update' ) ) { return $ this -> noPermission ( ) ; } $ category = Category :: find ( $ id ) ; $ featuredImage = Media :: find ( $ category -> featuredImageID ) ; if ( $ category ) { $ media = [ ] ; if ( $ featuredImage ) { $ media...
JSON object with details for a specific category . All data used in update form .
8,632
public function makeSearch ( $ lang , $ postTypeID , $ term ) { if ( ! User :: hasAccess ( 'Categories' , 'read' ) ) { return $ this -> noPermission ( ) ; } $ orderBy = ( isset ( $ _GET [ 'order' ] ) ) ? $ _GET [ 'order' ] : 'categoryID' ; $ orderType = ( isset ( $ _GET [ 'type' ] ) ) ? $ _GET [ 'type' ] : 'ASC' ; $ co...
Make simple search using term returns array of data that meet the term search .
8,633
public function getAllWithoutPagination ( $ lang = "" ) { $ result = DB :: table ( 'categories' ) -> join ( 'post_type' , 'post_type.postTypeID' , 'categories.postTypeID' ) -> orderBy ( 'name' , 'postTypeID' ) -> get ( ) ; return Language :: filterRows ( $ result , false ) ; }
Get all categories without pagination .
8,634
public function getPostType ( $ lang = "" , $ categoryID ) { $ result = DB :: table ( 'categories' ) -> join ( 'post_type' , 'post_type.postTypeID' , 'categories.postTypeID' ) -> where ( 'categoryID' , $ categoryID ) -> first ( ) ; return array ( 'list' => $ result ) ; }
Get post type by category id .
8,635
public function headers ( ) : Headers { return ! is_null ( $ this -> headers ) ? $ this -> headers : ( $ this -> headers = new Headers ( ) ) ; }
Retrieve object s headers
8,636
public function GenerateQrCode ( bool $ mustJoin = FALSE , bool $ needsActivation = FALSE , int $ acls = GnMashupLoginAcl :: None ) { $ qrCode = parent :: GenerateQrCodeInternal ( NULL , $ mustJoin , $ needsActivation , $ acls ) ; return $ qrCode ; }
Generate the login QR - code for the end - user .
8,637
private function getRenderer ( array $ options ) { if ( $ options [ 'text' ] ) { if ( $ options [ 'badge' ] ) { return function ( TagInterface $ tag ) { return sprintf ( '<span class="label label-%s"><i class="fa fa-%s"></i> %s</span>' , $ tag -> getTheme ( ) , $ tag -> getIcon ( ) , $ tag -> getName ( ) ) ; } ; } else...
Returns the renderer .
8,638
public function offsetGet ( $ offset ) { return isset ( $ this -> fields [ $ offset ] ) ? $ this -> fields [ $ offset ] : null ; }
Array get implementation .
8,639
protected function getValidator ( ) { $ validator = $ this -> createValidator ( ) ; $ constrains = [ ] ; $ messages = [ ] ; foreach ( $ this -> fields as $ name => $ field ) { if ( $ field instanceof Field ) { if ( $ field_rules = $ field -> getValidationRules ( ) ) $ constrains [ $ name ] = $ field_rules ; if ( $ fiel...
Return a validator .
8,640
protected function setErrors ( \ Asgard \ Validation \ Report $ errors ) { foreach ( $ errors -> attributes ( ) as $ name => $ _errors ) { if ( isset ( $ this -> fields [ $ name ] ) ) $ this -> fields [ $ name ] -> setErrors ( $ _errors ) ; } }
Set errors .
8,641
protected function parseFields ( $ fields , $ name ) { if ( is_array ( $ fields ) ) { return new self ( $ fields , $ name , ( isset ( $ this -> data [ $ name ] ) ? $ this -> data [ $ name ] : [ ] ) , $ this ) ; } elseif ( $ fields instanceof Field ) { $ field = $ fields ; $ field -> setName ( $ name ) ; $ field -> setP...
Parse new fields .
8,642
protected function _save ( $ group = null ) { if ( ! $ group ) $ group = $ this ; $ group -> doSave ( ) ; if ( $ group instanceof self ) { foreach ( $ group -> fields as $ name => $ field ) { if ( $ field instanceof self ) $ field -> _save ( $ field ) ; } } }
Save the group and its children .
8,643
protected function updateChilds ( ) { foreach ( $ this -> fields as $ name => $ field ) { if ( $ field instanceof self ) { $ field -> setData ( ( isset ( $ this -> data [ $ name ] ) ? $ this -> data [ $ name ] : [ ] ) ) ; } elseif ( $ field instanceof Field ) { if ( isset ( $ this -> data [ $ name ] ) ) $ field -> setV...
Update children data .
8,644
protected function myErrors ( $ validationGroups = [ ] ) { $ data = $ this -> data ; $ report = $ this -> getValidator ( ) -> errors ( $ data , $ validationGroups ) ; foreach ( $ this -> fields as $ name => $ field ) { if ( $ field instanceof Field \ FileField && isset ( $ this -> data [ $ name ] ) ) { $ f = $ this -> ...
Return the group own errors .
8,645
protected function getReportErrors ( \ Asgard \ Validation \ Report $ report ) { if ( $ report -> attributes ( ) ) { $ errors = [ ] ; foreach ( $ report -> attributes ( ) as $ attribute => $ attrReport ) { $ attrErrors = $ this -> getReportErrors ( $ attrReport ) ; if ( $ attrErrors ) $ errors [ $ attribute ] = $ attrE...
Return array of errors from a report .
8,646
public function filterModelsByIndex ( $ indexes ) { $ this -> filteredIndexes = array_merge ( $ this -> filteredIndexes , $ indexes ) ; $ this -> filteredIndexCount = count ( $ this -> filteredIndexes ) ; }
Excludes the array of indexes from the list of selected rows .
8,647
public final function setAugmentationData ( $ data ) { foreach ( $ data as $ id => $ rowData ) { if ( ! isset ( $ this -> augmentationData [ $ id ] ) ) { $ this -> augmentationData [ $ id ] = $ rowData ; } else { $ this -> augmentationData [ $ id ] = array_merge ( $ this -> augmentationData [ $ id ] , $ rowData ) ; } i...
Sets the augmentation data for the collection .
8,648
public function setChildren ( array $ components = [ ] ) { self :: removeAll ( $ components ) ; $ this -> children = $ components ; $ this -> attach ( $ components ) ; }
Replaces the current children with the supplied ones .
8,649
public function getIndex ( ) { if ( ! isset ( $ this -> parent ) ) throw new ComponentException ( $ this , "The component is not attached to a parent." ) ; if ( ! $ this -> parent -> children ) throw new ComponentException ( $ this , "The parent component has no children." ) ; return array_search ( $ this , $ this -> p...
Returns the ordinal index of this component on the parent s child list .
8,650
public function removeChildren ( ) { $ children = $ this -> children ; $ this -> children = [ ] ; if ( $ children ) self :: detachAll ( $ children ) ; return $ children ; }
Removes detaches and returns the component s children .
8,651
public function replaceBy ( array $ components = null ) { $ p = $ this -> getIndex ( ) ; if ( $ p !== false ) { array_splice ( $ this -> parent -> children , $ p , 1 , $ components ) ; $ this -> parent -> attach ( $ components ) ; } else { $ t = ComponentInspector :: inspectSet ( $ this -> parent -> children ) ; throw ...
Replaces the component by the specified componentes on the parent s child list . The component itself is discarded from the components tree .
8,652
private function generateRequestToken ( ) { if ( $ this -> getOption ( 'callback' ) ) { $ parameters = array ( 'oauth_callback' => $ this -> getOption ( 'callback' ) , ) ; } else { $ parameters = array ( ) ; } $ response = $ this -> oauthRequest ( $ this -> getOption ( 'requestTokenURL' ) , 'POST' , $ parameters ) ; pa...
Method used to get a request token .
8,653
private function authorise ( ) { $ url = $ this -> getOption ( 'authoriseURL' ) . '?oauth_token=' . $ this -> token [ 'key' ] ; if ( $ this -> getOption ( 'scope' ) ) { $ scope = \ is_array ( $ this -> getOption ( 'scope' ) ) ? implode ( ' ' , $ this -> getOption ( 'scope' ) ) : $ this -> getOption ( 'scope' ) ; $ url ...
Method used to authorise the application .
8,654
public function oauthRequest ( $ url , $ method , $ parameters , $ data = array ( ) , $ headers = array ( ) ) { $ defaults = array ( 'oauth_consumer_key' => $ this -> getOption ( 'consumer_key' ) , 'oauth_signature_method' => 'HMAC-SHA1' , 'oauth_version' => '1.0' , 'oauth_nonce' => $ this -> generateNonce ( ) , 'oauth...
Method used to make an OAuth request .
8,655
private function createHeader ( $ parameters ) { $ header = 'OAuth ' ; foreach ( $ parameters as $ key => $ value ) { if ( ! strcmp ( $ header , 'OAuth ' ) ) { $ header .= $ key . '="' . $ this -> safeEncode ( $ value ) . '"' ; } else { $ header .= ', ' . $ key . '="' . $ value . '"' ; } } return $ header ; }
Method used to create the header for the POST request .
8,656
public function toUrl ( $ url , $ parameters ) { foreach ( $ parameters as $ key => $ value ) { if ( \ is_array ( $ value ) ) { foreach ( $ value as $ k => $ v ) { if ( strpos ( $ url , '?' ) === false ) { $ url .= '?' . $ key . '=' . $ v ; } else { $ url .= '&' . $ key . '=' . $ v ; } } } else { if ( strpos ( $ value ...
Method to create the URL formed string with the parameters .
8,657
private function baseString ( $ url , $ method , $ parameters ) { uksort ( $ parameters , 'strcmp' ) ; foreach ( $ parameters as $ key => $ value ) { $ key = $ this -> safeEncode ( $ key ) ; if ( \ is_array ( $ value ) ) { foreach ( $ value as $ k => $ v ) { $ v = $ this -> safeEncode ( $ v ) ; $ kv [ ] = "{$key}={$v}"...
Prepare the signature base string .
8,658
protected function updateComposer ( $ dir ) { if ( strtoupper ( substr ( PHP_OS , 0 , 3 ) ) === 'WIN' ) $ cmd = '"vendor/bin/composer.bat" update --working-dir "' . $ dir . '"' ; else $ cmd = './vendor/bin/composer update --working-dir "' . $ dir . '"' ; return $ this -> runCommand ( $ cmd ) ; }
Update composer .
8,659
public function addSlide ( Slide $ slide ) { if ( ! $ this -> slides -> contains ( $ slide ) ) { $ this -> slides -> add ( $ slide ) ; $ slide -> setSlideShow ( $ this ) ; } return $ this ; }
Adds the slide .
8,660
public function removeSlide ( Slide $ slide ) { if ( $ this -> slides -> contains ( $ slide ) ) { $ this -> slides -> removeElement ( $ slide ) ; $ slide -> setSlideShow ( null ) ; } return $ this ; }
Removes the slide .
8,661
public function isActive ( $ path , $ strict = false ) { $ pathData = parse_url ( $ path ) ; if ( ! empty ( $ pathData [ 'scheme' ] ) || ! empty ( $ pathData [ 'host' ] ) || ! empty ( $ pathData [ 'port' ] ) || ! empty ( $ pathData [ 'user' ] ) || ! empty ( $ pathData [ 'pass' ] ) ) { return false ; } $ path = $ pathDa...
Whether the passed link is actual - is some descendant opened currently
8,662
public function isPropertyValueEmpty ( $ name ) { $ value = $ this -> getBlockExecutionContext ( ) -> controller -> getProperty ( $ name ) -> getValue ( ) ; return empty ( $ value ) ; }
Gets if specified property value is empty .
8,663
public function getLocalization ( $ locale ) { $ dataCollection = $ this -> getLocalizations ( ) ; $ data = $ dataCollection -> get ( $ locale ) ; return $ data ; }
Get data item by locale
8,664
public function buildQuery ( ) { foreach ( $ this -> fields as $ _nextRow ) { $ this -> columns [ $ _nextRow [ 'name' ] ] = $ this -> buildNextField ( $ _nextRow ) ; } }
Build all table rows from config
8,665
protected static function prepStr ( $ str , $ countSymb = 255 ) { $ len = strlen ( $ str ) ; $ len = $ len > $ countSymb ? $ countSymb : $ len ; return substr ( $ str , 0 , $ len ) ; }
Prepare fix string length
8,666
public static function getNameForeignKey ( $ tableName , $ tableNameRelated , $ fieldName , $ fieldNameRelated , $ wordWrap = false ) { return is_bool ( $ wordWrap ) ? 'fk_' . self :: prepStr ( $ tableName ) . '_' . self :: prepStr ( $ fieldName ) . '_' . self :: prepStr ( $ tableNameRelated ) . '_' . self :: prepStr (...
Auto generate next foreign key name
8,667
public function setAttribute ( $ attribute , $ value ) { if ( $ attribute === \ PDO :: ATTR_ERRMODE ) { throw new Exception \ InvalidArgumentException ( 'Doll does not allow to change PDO::ATTR_ERRMODE.' ) ; } if ( $ attribute === \ PDO :: ATTR_STATEMENT_CLASS ) { throw new Exception \ InvalidArgumentException ( 'Doll ...
When setAttribute is used prior to connecting to the database the attribute is logged . When setAttribute is used after connecting to the database the attribute is applied . The logged attributes are automatically applied after connecting to the database .
8,668
public function on ( $ method , $ statement , $ execution_wall_time = null , array $ parameters = [ ] ) { if ( $ method === 'prepare' || ! $ this -> getAttribute ( \ Gajus \ Doll \ PDO :: ATTR_LOGGING ) ) { return ; } $ statement = trim ( preg_replace ( '/\s+/' , ' ' , str_replace ( "\n" , ' ' , $ statement ) ) ) ; $ b...
This has to be public since it is accessed by the instance of \ Gajus \ Doll \ PDOStatement .
8,669
private function connect ( ) { if ( $ this -> isConnected ( ) ) { return ; } parent :: __construct ( $ this -> data_source -> getDSN ( ) , $ this -> data_source -> getUser ( ) , $ this -> data_source -> getPassword ( ) , $ this -> data_source -> getDriverOptions ( ) ) ; parent :: setAttribute ( \ PDO :: ATTR_EMULATE_PR...
Connect to the database using the constructor parameter and attributes that were collected prior to triggering connection to the database .
8,670
public function exec ( ) { $ this -> buildHttpHeader ( ) ; $ parameters = [ 'headers' => $ this -> headers , 'body' => $ this -> postFields , 'curl' => $ this -> setPostCurlopts ( ) , ] ; return $ this -> sendData ( 'POST' , $ parameters ) ; }
Execute the stored procedure
8,671
public static function fromGlobals ( array $ server = null , array $ query = null , array $ body = null , array $ cookies = null , array $ files = null ) { $ server = \ Zend \ Diactoros \ normalizeServer ( $ server ? : $ _SERVER ) ; $ files = \ Zend \ Diactoros \ normalizeUploadedFiles ( $ files ? : $ _FILES ) ; $ head...
Create an instance from globals
8,672
public function getCookie ( $ key = null , $ default = null , $ mode = null ) { return $ this -> getValue ( $ this -> getCookieParams ( ) , $ key , $ default , $ mode ) ; }
Gets a value from a cookie that came with the request
8,673
public function getQuery ( $ key = null , $ default = null , $ mode = null ) { return $ this -> getValue ( $ this -> getQueryParams ( ) , $ key , $ default , $ mode ) ; }
Get a GET param from the request URL
8,674
public function getAuthorization ( ) { if ( ! $ this -> hasHeader ( 'Authorization' ) ) { return null ; } $ temp = explode ( ' ' , trim ( $ this -> getHeaderLine ( 'Authorization' ) ) , 2 ) ; switch ( strtolower ( $ temp [ 0 ] ) ) { case 'basic' : $ temp [ 1 ] = base64_decode ( $ temp [ 1 ] ) ; $ temp [ 1 ] = explode (...
Get any authorization details supplied with the request .
8,675
public function isCors ( ) { if ( ! $ this -> hasHeader ( 'Origin' ) ) { return false ; } $ origin = parse_url ( $ this -> getHeaderLine ( 'Origin' ) ) ; $ host = $ this -> getUri ( ) -> getHost ( ) ; $ scheme = $ this -> getUri ( ) -> getScheme ( ) ; return ( ! $ host || strtolower ( $ origin [ 'scheme' ] ?? '' ) !== ...
Determine if this is an CORS request
8,676
public function getPreferredResponseFormats ( $ default = 'text/html' ) { $ acpt = $ this -> getHeaderLine ( 'Accept' ) ? : $ default ; $ acpt = explode ( ',' , $ acpt ) ; foreach ( $ acpt as $ k => $ v ) { $ v = array_pad ( explode ( ';' , $ v , 2 ) , 2 , 'q=1' ) ; $ v [ 1 ] = ( float ) array_pad ( explode ( 'q=' , $ ...
Get the prefered response formats .
8,677
public function count ( ) { if ( ! $ this -> initialized ) $ this -> initialize ( ) ; return count ( $ this -> elements ) - count ( $ this -> toRemove ) + count ( $ this -> toAdd ) ; }
Return number of elements .
8,678
private function parseQuery ( $ string ) { $ return = array ( ) ; $ parts = explode ( "&" , $ string ) ; foreach ( $ parts as $ part ) { list ( $ key , $ value ) = explode ( '=' , $ part , 2 ) ; $ value = urldecode ( $ value ) ; if ( isset ( $ return [ $ key ] ) ) { if ( ! is_array ( $ return [ $ key ] ) ) { $ return [...
Our own version of parse_str that allows for multiple variables with the same name .
8,679
private function buildQuery ( $ parts ) { $ return = array ( ) ; foreach ( $ parts as $ key => $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ v ) { $ return [ ] = urlencode ( $ key ) . "=" . urlencode ( $ v ) ; } continue ; } $ return [ ] = urlencode ( $ key ) . "=" . urlencode ( $ value ) ; } return ...
A version of build query that allows for multiple duplicate keys .
8,680
public function resetAction ( Request $ request ) { if ( ! $ request -> request -> has ( 'user_id' ) ) { throw new CmsException ( null , 'User id is not set' ) ; } $ userId = $ request -> request -> get ( 'user_id' ) ; $ user = $ this -> container -> getDoctrine ( ) -> getRepository ( 'CmsAuthentication:User' ) -> find...
Password reset action
8,681
public function deleteAction ( Request $ request ) { if ( ! $ request -> request -> get ( 'user_id' ) ) { throw new CmsException ( null , 'User id is not set' ) ; } $ userId = $ request -> request -> get ( 'user_id' ) ; $ currentUser = $ this -> getUser ( ) ; $ currentUserId = $ currentUser -> getId ( ) ; if ( $ curren...
Delete user action
8,682
public function createBlockAction ( Request $ request ) { $ row = $ this -> findRowByRequest ( $ request ) ; $ type = $ request -> request -> get ( 'type' , null ) ; try { $ block = $ this -> getEditor ( ) -> createDefaultBlock ( $ type , [ ] , $ row ) ; } catch ( EditorExceptionInterface $ e ) { return $ this -> handl...
Create and append a new block to the row .
8,683
public function layoutAction ( Request $ request ) { $ row = $ this -> findRowByRequest ( $ request ) ; $ data = $ request -> request -> get ( 'data' , [ ] ) ; try { $ this -> getEditor ( ) -> getLayoutAdapter ( ) -> updateRowLayout ( $ row , $ data ) ; } catch ( EditorExceptionInterface $ e ) { return $ this -> handle...
Updates the row layout .
8,684
public function removeAction ( Request $ request ) { $ row = $ this -> findRowByRequest ( $ request ) ; $ container = $ row -> getContainer ( ) ; try { $ this -> getEditor ( ) -> getRowManager ( ) -> delete ( $ row ) ; } catch ( EditorExceptionInterface $ e ) { return $ this -> handleException ( $ e ) ; } $ removedId =...
Remove the row .
8,685
public function moveDownAction ( Request $ request ) { $ row = $ this -> findRowByRequest ( $ request ) ; try { $ sibling = $ this -> getEditor ( ) -> getRowManager ( ) -> moveDown ( $ row ) ; } catch ( EditorExceptionInterface $ e ) { return $ this -> handleException ( $ e ) ; } $ container = $ row -> getContainer ( )...
Move down the row .
8,686
public function grant ( $ ability ) { if ( ! in_array ( $ ability , $ this -> abilities ) ) { return $ this -> abilities = array_merge ( [ $ ability ] , $ this -> abilities ) ; } return true ; }
Grant an ability .
8,687
public function revoke ( $ ability ) { if ( in_array ( $ ability , $ this -> abilities ) ) { return $ this -> abilities = array_values ( array_diff ( $ this -> abilities , [ $ ability ] ) ) ; } return true ; }
Revoke an ability .
8,688
public function getLastUpdatedAt ( ) { $ qb = $ this -> createQueryBuilder ( 'p' ) ; $ date = $ qb -> select ( 'p.updatedAt' ) -> addOrderBy ( 'p.updatedAt' , 'DESC' ) -> getQuery ( ) -> setMaxResults ( 1 ) -> getSingleScalarResult ( ) ; if ( null !== $ date ) { return new \ DateTime ( $ date ) ; } return null ; }
Returns the last updated at date time .
8,689
public function findOneByRoute ( $ routeName ) { $ qb = $ this -> getQueryBuilder ( 'p' ) ; return $ qb -> leftJoin ( 'p.seo' , 's' ) -> leftJoin ( 's.translations' , 's_t' , Expr \ Join :: WITH , $ this -> getLocaleCondition ( 's_t' ) ) -> addSelect ( 's' , 's_t' ) -> andWhere ( $ qb -> expr ( ) -> eq ( 'p.route' , ':...
Finds a page by request .
8,690
public function getPagesRoutes ( ) { $ qb = $ this -> createQueryBuilder ( 'p' ) ; $ results = $ qb -> select ( 'p.route' ) -> getQuery ( ) -> getScalarResult ( ) ; return array_column ( $ results , 'route' ) ; }
Returns the pages routes .
8,691
public function addDirectory ( $ path ) { $ finder = new \ Symfony \ Component \ Finder \ Finder ( ) ; $ patterns = $ this -> getIgnorePatterns ( ) -> getRegularExpression ( ) ; if ( $ this -> follow_symlinks ) { $ finder -> followLinks ( ) ; } $ finder -> files ( ) -> in ( $ path ) -> name ( '/\.(' . implode ( '|' , $...
Retrieve all files in the given directory and add them to the parsing list .
8,692
public function addFile ( $ path ) { $ paths = $ this -> getGlobbedPaths ( $ path ) ; foreach ( $ paths as $ path ) { $ file = new File ( $ path ) ; $ path = $ file -> getRealPath ( ) ? $ file -> getRealPath ( ) : $ file -> getPathname ( ) ; $ this [ $ path ] = $ file ; } }
Adds a file to the collection .
8,693
public function getProjectRoot ( ) { $ base = '' ; $ files = array_keys ( $ this -> getArrayCopy ( ) ) ; $ parts = explode ( DIRECTORY_SEPARATOR , reset ( $ files ) ) ; foreach ( $ parts as $ part ) { $ base_part = $ base . $ part . DIRECTORY_SEPARATOR ; foreach ( $ files as $ dir ) { if ( substr ( $ dir , 0 , strlen (...
Calculates the project root from the given files by determining their highest common path .
8,694
public function addChoice ( \ DOMElement $ node ) { if ( $ node -> nodeName != 'input' ) return ; $ inputValue = $ node -> getAttribute ( 'value' ) ; $ this -> choices [ ] = $ inputValue ; switch ( $ node -> getAttribute ( 'type' ) ) { case 'radio' : if ( $ node -> getAttribute ( 'checked' ) == 'checked' ) $ this -> va...
Add a choice to the field .
8,695
protected function getPath ( $ name ) { $ path = [ ] ; $ matches = null ; preg_match ( '/^([^\[]+)/' , $ name , $ matches ) ; $ path [ ] = $ matches [ 0 ] ; preg_match_all ( '/\[([^\]]*)\]/' , $ name , $ matches ) ; $ path = array_merge ( $ path , $ matches [ 1 ] ) ; return $ path ; }
Get a field path .
8,696
public function values ( ) { $ res = [ ] ; foreach ( $ this -> fields as $ name => $ field ) { $ value = $ field -> getValue ( ) ; if ( $ value === null ) continue ; if ( ( $ field -> getType ( ) == 'image' || $ field -> getType ( ) == 'submit' ) && $ name !== $ this -> submit ) continue ; $ path = $ this -> getPath ( ...
Get form values .
8,697
public static function parse ( $ html , $ xpath ) { $ doc = new \ DOMDocument ( ) ; $ doc -> loadHTML ( $ html ) ; $ domxpath = new \ DOMXPath ( $ doc ) ; $ node = $ domxpath -> evaluate ( $ xpath ) -> item ( 0 ) ; return new static ( $ node ) ; }
Parse the HTML form .
8,698
public static function extractLocaleSegmentFromParameters ( Scope $ scope , string $ routeKey , array & $ parameters = [ ] ) { $ localeSegment = null ; if ( ! array_key_exists ( $ routeKey , $ parameters ) || is_null ( $ parameters [ $ routeKey ] ) ) { return $ scope -> activeSegment ( ) ; } if ( $ scope -> validateSeg...
Isolate locale value from parameters .
8,699
public function setBatch ( $ size , array $ replace = [ ] ) { $ this -> batch_size = $ size ; $ this -> batch_replace = $ replace ; return $ this ; }
Set insert batch size and replace parameters .