idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
10,700
public function delete_user_option ( string $ id_option , string $ id_user = null ) : ? int { if ( $ id_option = $ this -> _get_id_option ( $ id_option ) ) { return $ this -> db -> delete ( $ this -> class_cfg [ 'table' ] , [ $ this -> fields [ 'id_option' ] => $ id_option , $ this -> fields [ 'id_user' ] => $ id_user ...
Deletes all the given or current user s permissions for the given option
10,701
public function delete_group_option ( string $ id_option , string $ id_group ) : ? int { if ( $ id_option = $ this -> _get_id_option ( $ id_option ) ) { return $ this -> db -> delete ( $ this -> class_cfg [ 'table' ] , [ $ this -> fields [ 'id_option' ] => $ id_option , $ this -> fields [ 'id_group' ] => $ id_group ] )...
Deletes all the given group s permissions for the given option
10,702
public function get_shared ( string $ id ) : ? array { if ( bbn \ str :: is_uid ( $ id ) ) { return $ this -> db -> rselect_all ( $ this -> class_table , [ $ this -> fields [ 'id' ] , $ this -> fields [ 'id_user' ] , $ this -> fields [ 'id_group' ] ] , [ $ this -> fields [ 'id_alias' ] => $ id ] ) ; } return null ; }
Returns an array
10,703
public function add_bit ( string $ id_usr_opt , array $ cfg ) : ? string { if ( ( $ id_usr_opt = $ this -> _get_id_option ( $ id_usr_opt ) ) && ( $ c = $ this -> class_cfg [ 'arch' ] [ 'user_options_bits' ] ) ) { $ to_cfg = $ this -> get_bit_cfg ( null , $ cfg ) ; if ( isset ( $ to_cfg [ 'items' ] ) ) { unset ( $ to_cf...
Adds a bit to a preference
10,704
public function delete_bit ( string $ id ) : ? int { if ( \ bbn \ str :: is_uid ( $ id ) ) { return $ this -> db -> delete ( $ this -> class_cfg [ 'tables' ] [ 'user_options_bits' ] , [ $ this -> class_cfg [ 'arch' ] [ 'user_options_bits' ] [ 'id' ] => $ id ] ) ; } return null ; }
Deletes a preference s bit
10,705
public function update_bit ( string $ id , array $ cfg , $ merge_config = false ) : ? int { if ( \ bbn \ str :: is_uid ( $ id ) ) { $ c = $ this -> class_cfg [ 'arch' ] [ 'user_options_bits' ] ; $ fields = array_values ( $ c ) ; if ( \ array_key_exists ( $ c [ 'id' ] , $ cfg ) ) { unset ( $ cfg [ $ c [ 'id' ] ] ) ; } $...
Updates a preference s bit
10,706
public function get_bit ( string $ id , bool $ with_config = true ) : array { if ( \ bbn \ str :: is_uid ( $ id ) && ( $ bit = $ this -> db -> rselect ( $ this -> class_cfg [ 'tables' ] [ 'user_options_bits' ] , [ ] , [ $ this -> class_cfg [ 'arch' ] [ 'user_options_bits' ] [ 'id' ] => $ id ] ) ) ) { if ( ! empty ( $ w...
Returns a single preference s bit
10,707
public function get_bits ( string $ id_usr_opt , $ id_parent = false , bool $ with_config = true ) : array { $ c = $ this -> class_cfg [ 'arch' ] [ 'user_options_bits' ] ; $ t = $ this ; $ where = [ $ c [ 'id_user_option' ] => $ id_usr_opt ] ; if ( is_null ( $ id_parent ) || \ bbn \ str :: is_uid ( $ id_parent ) ) { $ ...
Returns the bits list of a preference
10,708
public function get_full_bits ( string $ id_usr_opt , string $ id_parent = null , bool $ with_config = true ) : array { if ( \ bbn \ str :: is_uid ( $ id_usr_opt ) ) { $ c = $ this -> class_cfg [ 'arch' ] [ 'user_options_bits' ] ; $ t = $ this ; return array_map ( function ( $ b ) use ( $ t , $ c , $ id_usr_opt , $ wit...
Returns the hierarchical bits list of a preference
10,709
public function get_tree ( string $ id , bool $ with_config = true ) : array { if ( \ bbn \ str :: is_uid ( $ id ) && ( $ p = $ this -> get ( $ id , $ with_config ) ) ) { $ p [ 'items' ] = $ this -> get_full_bits ( $ id , null , $ with_config ) ; return $ p ; } return [ ] ; }
Returns a preference and its hierarchical bits list
10,710
public function order_bit ( string $ id , int $ pos ) : ? bool { if ( \ bbn \ str :: is_uid ( $ id ) && ( $ cf = $ this -> get_class_cfg ( ) ) && ( $ cfg = $ cf [ 'arch' ] [ 'user_options_bits' ] ) && ( $ bit = $ this -> get_bit ( $ id ) ) && ( $ old = ( int ) $ bit [ $ cfg [ 'num' ] ] ) && ! empty ( $ pos ) && ( $ old...
Orders a bit .
10,711
public function move_bit ( string $ id , string $ id_parent = null ) : ? bool { if ( \ bbn \ str :: is_uid ( $ id ) && ( ( \ bbn \ str :: is_uid ( $ id_parent ) && $ this -> get_bit ( $ id_parent ) ) || \ is_null ( $ id_parent ) ) && ( $ bit = $ this -> get_bit ( $ id ) ) && ( $ cf = $ this -> get_class_cfg ( ) ) && ( ...
Moves a bit .
10,712
public function get_max_bit_num ( string $ id_user_option , string $ id_parent = null , bool $ incr = false ) : int { if ( \ bbn \ str :: is_uid ( $ id_user_option ) && ( \ bbn \ str :: is_uid ( $ id_parent ) || is_null ( $ id_parent ) ) && ( $ cf = $ this -> get_class_cfg ( ) ) && ( $ cfg = $ cf [ 'arch' ] [ 'user_opt...
Gets the maximum num value of the user option s bits .
10,713
public function get_by_bit ( string $ id ) : ? array { $ t = & $ this ; if ( \ bbn \ str :: is_uid ( $ id ) ) { return $ this -> db -> rselect ( [ 'table' => $ this -> class_cfg [ 'table' ] , 'fields' => array_map ( function ( $ v ) use ( $ t ) { return $ this -> class_cfg [ 'table' ] . '.' . $ v ; } , array_values ( $...
Gets a preference row from a bit ID
10,714
public function get_id_by_bit ( string $ id ) : ? string { if ( \ bbn \ str :: is_uid ( $ id ) && ( $ p = $ this -> get_by_bit ( $ id ) ) ) { return $ p [ $ this -> fields [ 'id' ] ] ; } return null ; }
Gets the preference s ID from a bit ID
10,715
private function selectRestVersion ( $ channelXml , $ supportedVersions ) { $ channelXml -> registerXPathNamespace ( 'ns' , self :: CHANNEL_NS ) ; foreach ( $ supportedVersions as $ version ) { $ xpathTest = "ns:servers/ns:primary/ns:rest/ns:baseurl[@type='{$version}']" ; $ testResult = $ channelXml -> xpath ( $ xpathT...
Reads channel supported REST interfaces and selects one of them
10,716
public function get ( $ id ) { return $ this -> _sendPayload ( $ this -> _getService ( $ this -> _pageServiceKey ) -> getActiveTemplateSections ( $ id ) ) ; }
Get template sections
10,717
public function update ( $ id , $ data ) { $ sections = empty ( $ data [ 'sections' ] ) ? [ ] : $ data [ 'sections' ] ; return $ this -> _sendPayload ( $ this -> _getService ( $ this -> _pageServiceKey ) -> updateTemplateSections ( $ id , $ sections ) ) ; }
Update section details
10,718
public function getRowUrl ( $ item ) { if ( ! $ item instanceof Varien_Object ) { return parent :: getRowUrl ( $ item ) ; } $ rowUrlRoute = trim ( $ this -> getRowUrlRoute ( ) ) ; if ( empty ( $ rowUrlRoute ) ) { return parent :: getRowUrl ( $ item ) ; } $ params = [ ] ; $ rowUrlParams = $ this -> getRowUrlParams ( ) ;...
Return row url for js event handlers
10,719
public function sortColumnsByOrder ( ) { $ columns = $ this -> _columns ; foreach ( $ this -> getColumnsOrder ( ) as $ columnId => $ after ) { if ( $ after [ 0 ] === '-' ) { $ before = substr ( $ after , 1 ) ; $ after = null ; } else { $ before = null ; } if ( $ after !== null && isset ( $ columns [ $ after ] ) ) { $ c...
Sort columns by predefined order
10,720
public function updateColumn ( $ columnId , $ key , $ value ) { if ( isset ( $ this -> _columns [ $ columnId ] ) && $ this -> _columns [ $ columnId ] instanceof Varien_Object ) { $ this -> _columns [ $ columnId ] -> setData ( $ key , $ value ) ; } return $ this ; }
Modify grid column
10,721
public function getCurrentProject ( ) { return $ this -> createInstance ( $ this -> environment -> getProjectType ( ) , $ this -> environment , $ this -> configuration , $ this -> fileSystem ) ; }
Get a project plugin for the current environment settings .
10,722
public function getKeyValue ( $ key ) { return empty ( $ this -> _data [ $ key ] ) ? null : $ this -> _data [ $ key ] ; }
Get data value by key
10,723
public function setThemeTemplate ( $ template ) { $ this -> _themeTemplate = $ template ; if ( $ this -> getTheme ( ) != null ) { $ this -> getTheme ( ) -> setTemplate ( $ this -> _themeTemplate ) ; } }
Set Theme Template
10,724
public function getProcessedFields ( ) { return [ 'page' => $ this -> getPage ( ) , 'perPage' => $ this -> getPerPage ( ) , 'filter' => $ this -> filter , 'orderBy' => $ this -> orderBy , 'query' => $ this -> searchQuery ] ; }
Returns array with all processed fields
10,725
private function processFilterParams ( $ key , $ param ) { $ this -> filter [ ] = [ $ key , '=' , ( is_numeric ( $ param ) ) ? ( float ) $ param : $ param ] ; }
Process filter params
10,726
public function draw ( $ text , $ size = 12 , $ x = 0 , $ y = 0 ) { imagettftext ( $ this -> image , $ size , $ this -> rotation , $ x , $ y , $ this -> text_color , $ this -> font , $ text ) ; return $ this -> image ; }
Draws the text onto the image
10,727
final public static function get_instance ( array $ setting = [ ] ) { $ class_name = get_called_class ( ) ; if ( ! isset ( self :: $ instances [ $ class_name ] ) ) { self :: $ instances [ $ class_name ] = new $ class_name ( $ setting ) ; } return self :: $ instances [ $ class_name ] ; }
Singleton initialize method
10,728
public static function getColumns ( array $ array , array $ columns , $ allRowsMustHaveAllColumns = false ) { foreach ( $ array as $ key => $ row ) { if ( ! is_array ( $ row ) ) { throw new UnexpectedValueException ( 'Array element "' . $ key . '" is not an array' ) ; } } foreach ( $ columns as $ key => $ column ) { if...
Extracts a column from an array
10,729
public static function getRectangularDimensions ( array $ array ) { $ return = - 1 ; $ allArrays = array_map ( 'is_array' , $ array ) ; if ( self :: allElementsEqual ( $ allArrays , true ) ) { $ elementsPerArray = array ( ) ; foreach ( $ array as $ row ) { $ noElements = self :: getRectangularDimensions ( $ row ) ; if ...
Checks if an array is rectangular array and returns dimensions or - 1 if it s not rectangular
10,730
public static function selectRandomArrayElements ( array $ array , $ numberOfRequiredElements ) { if ( ! self :: isLogicallyCastableToInt ( $ numberOfRequiredElements ) ) { throw new InvalidArgumentException ( 'Number of requested elements parameter must be a positive integer' ) ; } if ( $ numberOfRequiredElements <= 0...
Selects random sub array
10,731
protected function parseUri ( $ uriString = '' ) { $ status = @ preg_match ( "~^((//)([^/?#]*))([^?#]*)(\?([^#]*))?(#(.*))?$~" , $ uriString , $ matches ) ; if ( $ status === FALSE ) { throw new Exception ( "URI scheme-specific decomposition failed" ) ; } if ( ! $ status ) return ; $ this -> path = ( isset ( $ matches ...
Parses the scheme - specific portion of the URI and place its parts into instance variables .
10,732
public static function check ( $ uri ) { try { $ uri = new self ( strval ( $ uri ) ) ; } catch ( \ Exception $ e ) { return FALSE ; } return $ uri -> valid ( ) ; }
Returns TRUE if a given URI is valid .
10,733
public function checkPath ( $ path = null ) { if ( $ path === null ) { $ path = $ this -> path ; } if ( strlen ( $ path ) == 0 ) { return TRUE ; } $ pattern = "/^" . $ this -> regex [ "path" ] . "$/" ; $ status = @ preg_match ( $ pattern , $ path ) ; if ( $ status === FALSE ) { throw new Exception ( "URI path validatio...
Returns TRUE if the path is valid .
10,734
public static function getHostUri ( ) { $ sheme = ( self :: getHostParam ( "HTTPS" ) == "on" ) ? "https" : "http" ; $ serverName = new Str ( self :: getHostParam ( "HTTP_HOST" ) ) ; $ serverPort = self :: getHostParam ( "SERVER_PORT" ) ; $ serverPort = ( $ serverPort != 80 && $ serverPort != 443 ) ? ":" . $ serverPort ...
Returns the applications host address .
10,735
public function parseBody ( $ line ) { $ line = rtrim ( $ line , "\r\n" ) ; if ( $ this -> text === null ) { $ this -> text = $ line ; } else { $ this -> text .= "\n" . $ line ; } }
Adds each line to the body of the text part .
10,736
public function finish ( ) { $ charset = "us-ascii" ; if ( isset ( $ this -> headers [ 'Content-Type' ] ) ) { preg_match ( '/\s*charset\s?=\s?"?([^;"\s]*);?/' , $ this -> headers [ 'Content-Type' ] , $ parameters ) ; if ( count ( $ parameters ) > 0 ) { $ charset = strtolower ( trim ( $ parameters [ 1 ] , '"' ) ) ; } } ...
Returns the ezcMailText part corresponding to the parsed message .
10,737
public static function load ( $ class ) { $ file = static :: normalizePath ( $ class ) ; if ( file_exists ( $ path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . $ file ) ) { require $ path ; return true ; } foreach ( static :: $ directories as $ directory ) { if ( file_exis...
Search and Include a Class by class name like Qlake \ Router \ Route .
10,738
private function createWord ( ) { $ this -> word = '' ; for ( $ x = 0 ; $ x < rand ( 5 , 7 ) ; $ x ++ ) { $ this -> word .= $ this -> allowed_characters [ rand ( 0 , strlen ( $ this -> allowed_characters ) - 1 ) ] ; } return $ this -> word ; }
Creates the word from the allowed characters
10,739
public function addInterference ( ) { for ( $ i = 0 ; $ i < 20 ; $ i ++ ) { $ radius = rand ( 0 , 150 ) ; imageellipse ( $ this -> image , rand ( 0 , 200 ) , rand ( 0 , 200 ) , $ radius , $ radius , $ this -> ink_color ) ; } }
Adds interference as circles int he backgroun the make it more difficult to parse . This is optional
10,740
public function draw ( $ filters = Array ( ) ) { $ word = $ this -> createWord ( ) ; for ( $ j = 0 ; $ j < 5 ; $ j ++ ) { if ( file_exists ( $ this -> font ) ) { imagettftext ( $ this -> image , rand ( 8 , 18 ) , rand ( 0 , 30 ) , rand ( 0 , 200 ) , rand ( 0 , 200 ) , $ this -> ink_color , $ this -> font , 'not the cod...
Draws the wor text on the image using the true type font specified . If no font is specified than
10,741
public function nonce_field ( $ key = '_wpnonce' , $ referrer = false , $ echo = true ) { return wp_nonce_field ( $ this -> action , $ key , $ referrer , $ echo ) ; }
Echo nonce field
10,742
public static function view ( $ slug , $ name = '' , array $ args = [ ] ) { $ class_name = get_called_class ( ) ; $ instance = $ class_name :: get_instance ( ) ; $ instance -> lazy_scripts ( ) ; $ instance -> load_template ( $ slug , $ name , $ args ) ; }
Load view template with arguments
10,743
private function getExtendableFile ( $ specification ) { $ target = $ specification -> getTarget ( ) ; if ( ! array_key_exists ( $ target , $ this -> extendableFiles ) ) { if ( ! $ specification -> mayCreate ( ) ) return null ; $ this -> extendableFiles [ $ target ] = $ this -> getExtendableFileFromSpecification ( $ sp...
Creates an extendable file from a specification . If the extendable file was already created returns the cached extendable file . If the extendable file does not yet exist create it if it may be created from this specification .
10,744
private function generateFilesForArtifacts ( $ artifacts , $ fileSettingsGetter , $ extend ) { foreach ( $ artifacts as $ artifact ) { $ settings = $ artifact -> getGeneratorSettings ( static :: getKey ( ) ) ; foreach ( call_user_func ( array ( $ this , $ fileSettingsGetter ) , $ settings ) as $ file ) { $ specificatio...
Generates the extendable files for a set of artifacts and file settings .
10,745
protected function _generateFiles ( ) { $ this -> generateFilesForArtifacts ( $ this -> selectedArtifacts , "getFileSettingsForSelected" , false ) ; $ this -> generateFilesForArtifacts ( $ this -> deselectedArtifacts , "getFileSettingsForDeselected" , false ) ; $ this -> generateFilesForArtifacts ( $ this -> selectedAr...
Generates the extendable files .
10,746
final public function compile ( Buffer $ buffer ) { $ buffer -> writeln ( "Phar::mapPhar('z.phar');" ) -> writeln ( "define('ZPREFIX', 'phar://z.phar/');" ) -> writeln ( "require_once 'phar://z.phar/vendor/autoload.php';" ) ; $ this -> compileInitialization ( $ buffer ) ; $ buffer -> writeln ( '$app->run();' ) -> write...
Compiles into the specified buffer .
10,747
private function createNode ( $ nodeName , $ nodeValue , $ cdata = false ) { $ node = $ this -> createElement ( $ nodeName ) ; if ( $ cdata ) { $ text = $ this -> createCDATASection ( $ nodeValue ) ; } else { $ text = $ this -> createTextNode ( $ nodeValue ) ; } $ node -> appendChild ( $ text ) ; return $ node ; }
Creates and returns a new node with textNode ready for appending
10,748
private function appendItem ( \ sb \ RSS \ Item $ item ) { $ new_item = $ this -> createElement ( "item" ) ; foreach ( get_object_vars ( $ item ) as $ key => $ val ) { if ( $ item -> { $ key } instanceof \ sb \ RSS \ ItemEnclosure ) { $ enclosure = $ this -> createElement ( 'enclosure' ) ; foreach ( $ item -> { $ key }...
Takes an \ sb \ RSS \ Item and converts it into a DOMM node followed by inserting it into the feed DOM
10,749
private function channelPropertiesToDOM ( ) { foreach ( get_object_vars ( $ this ) as $ key => $ val ) { if ( is_string ( $ val ) && ! empty ( $ val ) ) { $ this -> channel -> appendChild ( $ this -> createNode ( $ key , $ val , $ key == 'description' ) ) ; } elseif ( $ this -> { $ key } instanceof \ sb \ RSS \ Image )...
Converts all the feed object properties into RSS DOM nodes and adds them to the channel node
10,750
public function unescapeCharacter ( $ value ) { switch ( $ value { 1 } ) { case '0' : return "\x0" ; case 'a' : return "\x7" ; case 'b' : return "\x8" ; case 't' : return "\t" ; case "\t" : return "\t" ; case 'n' : return "\n" ; case 'v' : return "\xb" ; case 'f' : return "\xc" ; case 'r' : return "\xd" ; case 'e' : re...
Unescapes a character that was found in a double - quoted string
10,751
public function toggle ( $ flag , $ name ) { switch ( $ flag ) { case 'on' : $ onoff = true ; break ; case 'off' : $ onoff = false ; break ; default : throw new \ InvalidArgumentException ( "Flag must be 'on' or 'off'" ) ; } switch ( $ name ) { case 'debug' : $ this -> debug = $ onoff ; break ; case 'info' : $ this -> ...
Sets the named attribute to true or false
10,752
private function audioCanBeEncoded ( $ resolution , $ metainfo ) { return $ resolution [ 'audio_sample_rate' ] >= $ metainfo [ 'sample_rate' ] && $ resolution [ 'audio_bitrate' ] <= $ metainfo [ 'max_bit_rate' ] || filter_var ( $ resolution [ 'allow_lower_audio_bitrate' ] , FILTER_VALIDATE_BOOLEAN ) ; }
determines if the the audiotrack meets minimum standards to be encoded
10,753
private function getMediaType ( $ metainfo ) { if ( $ metainfo [ 'audio' ] != false && ( $ metainfo [ 'video' ] == false || $ metainfo [ 'video' ] [ 'codec_name' ] == 'png' || $ metainfo [ 'video' ] [ 'codec_name' ] == 'jpg' ) ) { return $ this :: MEDIA_TYPE_AUDIO ; } if ( $ metainfo [ 'video' ] != false && $ metainfo ...
returns the mediatype depending on given metainfos MEDIA_TYPE_AUDIO if soundfile MEDIA_TYPE_VIDEO if videofile MEDIA_TYPE_VIDEO_ONLY if videofile without soundstream .
10,754
private function getMetainfoForEpisode ( $ episode ) { $ uri = $ this -> bprs_asset_helper -> getAbsoluteUrl ( $ episode -> getVideo ( ) ) ; if ( ! $ uri ) { $ this -> logbook -> error ( 'oktolab_media.episode_encode_no_streams' , [ ] , $ episode -> getUniqID ( ) ) ; return false ; } $ metainfo = json_decode ( shell_ex...
extracts streaminformations of an episode from its video .
10,755
public function init ( ) { if ( ! post_type_exists ( $ this -> post_type ) ) { $ post_type = register_post_type ( $ this -> post_type , $ this -> args ) ; if ( is_wp_error ( $ post_type ) ) { return $ post_type ; } } if ( '' !== $ this -> title_placeholder ) { add_filter ( 'enter_title_here' , array ( $ this , 'update_...
Function that register the CPT first tests if there is no such CPT on the site .
10,756
public function set_labels ( $ labels ) { $ this -> merge ( $ this -> labels , $ labels ) ; $ this -> update_arg ( 'labels' , $ this -> labels ) ; }
Allows to overwrite any of the default labels for this CPT just send an associate array with the value you want to update .
10,757
private function set_default_labels ( ) { $ this -> labels = array ( 'name' => $ this -> interpolate ( '%s' , $ this -> plural ) , 'singular_name' => $ this -> interpolate ( '%s' , $ this -> singular ) , 'add_new' => $ this -> interpolate ( 'Add New' ) , 'all_items' => $ this -> interpolate ( 'All %s' , $ this -> plura...
Creates the default labels to be used with this CPT .
10,758
public function set_supports ( $ support ) { if ( is_array ( $ support ) ) { $ this -> supports = $ support ; $ this -> update_arg ( 'supports' , $ this -> supports ) ; } }
Allow to update the default supports values for the CPT .
10,759
protected function detectFsRoot ( ) { Eresus_Kernel :: log ( __METHOD__ , LOG_DEBUG , 'start' ) ; switch ( true ) { case Eresus_Kernel :: isCLI ( ) : $ path = reset ( $ GLOBALS [ 'argv' ] ) ; Eresus_Kernel :: log ( __METHOD__ , LOG_DEBUG , 'Using global $argv variable: %s' , $ path ) ; $ path = dirname ( $ path ) ; bre...
Trying to determine application root directory
10,760
protected function resolvePath ( array $ originalPaths ) { $ paths = array ( ) ; foreach ( $ originalPaths as $ key => $ path ) { if ( count ( explode ( 'templates' , $ path ) ) == 1 ) { $ path = $ path . DIRECTORY_SEPARATOR . 'templates' ; } if ( realpath ( $ path ) ) { $ paths [ $ key ] = realpath ( $ path ) ; } } re...
Build an array for templates path directory
10,761
public function setLayout ( $ layout , array $ data = array ( ) ) { if ( is_null ( $ layout ) ) { $ this -> layout = null ; return ; } $ this -> layout = $ this -> make ( $ this -> resolve ( $ layout ) , $ data ) ; }
Manually set the layout
10,762
public function fetch ( $ template , $ data = array ( ) ) { $ view = $ this -> render ( $ template , $ data ) ; return ( $ view ) ? $ view -> render ( ) : '' ; }
Return the contents of a rendered template file
10,763
protected function render ( $ template , $ data = array ( ) ) { $ view = null ; $ data = array_merge_recursive ( $ this -> all ( ) , $ data ) ; $ data [ 'app' ] = $ this -> app ; $ template = $ this -> resolve ( $ template ) ; if ( ! $ template ) { return ; } if ( ! $ this -> layout ) { $ view = $ this -> make ( $ temp...
This method will output the rendered template content
10,764
public function resolve ( $ path ) { $ path = str_replace ( '/' , '.' , preg_replace ( '/\/:\w+/' , '' , $ path ) ) ; $ finder = $ this -> container [ 'view.finder' ] ; try { $ finder -> find ( $ path ) ; } catch ( InvalidArgumentException $ e ) { $ explodedPath = explode ( '.' , $ path ) ; if ( $ explodedPath [ 0 ] ==...
This method will try to find the existing of template file
10,765
public function rules ( ) { $ module = UsersModule :: module ( ) ; $ rules = [ [ [ 'phone' ] , 'safe' , ] , [ [ 'password' , ] , 'safe' , 'on' => self :: SCENARIO_DEFAULT , ] , [ [ 'password' , ] , 'required' , 'on' => self :: SCENARIO_PASSWORD_RESET , ] , [ 'username' , 'unique' , ] , [ 'email' , 'unique' , ] , 'stand...
Validation rules for this model .
10,766
public function afterFind ( ) { parent :: afterFind ( ) ; $ this -> username_is_temporary = boolval ( $ this -> username_is_temporary ) ; $ this -> is_active = boolval ( $ this -> is_active ) ; }
Performs after find action and casts attributes to proper type
10,767
public function register ( ) { if ( $ this -> getIsNewRecord ( ) == false ) { throw new \ RuntimeException ( 'Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user' ) ; } $ module = UsersModule :: module ( ) ; if ( empty ( $ this -> password ) === true ) { $ this -> password = PasswordHelper :: generate ( $ ...
This method is used to register new user account .
10,768
public function login ( $ loginDuration = 0 ) { $ loginStatus = Yii :: $ app -> getUser ( ) -> login ( $ this , $ loginDuration ) ; if ( $ loginStatus ) { $ this -> trigger ( User :: EVENT_LOGIN ) ; } return $ loginStatus ; }
Login user .
10,769
protected function getFileKey ( $ basePath , \ SplFileInfo $ file ) { $ baseLength = strlen ( rtrim ( $ basePath , DIRECTORY_SEPARATOR ) ) ; return substr ( $ file -> getPath ( ) , $ baseLength ) . DIRECTORY_SEPARATOR . $ file -> getBasename ( '.' . $ file -> getExtension ( ) ) ; }
Get relative key for a file
10,770
protected function isOutOfDate ( $ source , $ destination , array $ includes = null ) { $ includes = ( array ) $ includes ; $ extensions = $ this -> compiler -> getExtensions ( ) ; if ( ! file_exists ( $ destination ) ) { return true ; } if ( is_file ( $ source ) && is_file ( $ destination ) ) { $ sourceFiles = array (...
Test is destination file or folder is out of date from the source .
10,771
protected function scanDirectory ( $ path , $ extensions ) { if ( is_file ( $ path ) ) { $ file = new \ SplFileInfo ( $ path ) ; return array ( $ this -> getFileKey ( $ file -> getPath ( ) , $ file ) => $ file ) ; } $ files = array ( ) ; $ extensions = ( array ) $ extensions ; $ iterator = new \ RecursiveIteratorIterat...
Scan a directory and return a list of files with matching extenstions
10,772
public function actionCreate ( ) { $ model = new Address ( [ 'scenario' => 'create' ] ) ; Yii :: $ app -> response -> format = Response :: FORMAT_JSON ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { if ( $ model -> validate ( ) ) { if ( $ model -> save ( false ) ) { return $ this -> tree ( $ model ) ...
Create Address .
10,773
public function actionUpdate ( $ id ) { $ model = $ this -> findModel ( $ id ) ; $ model -> setScenario ( 'update' ) ; Yii :: $ app -> response -> format = Response :: FORMAT_JSON ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { if ( $ model -> validate ( ) ) { if ( $ model -> save ( false ) ) { retur...
Update Communication .
10,774
public function actionFetch ( $ id ) { $ model = $ this -> findModel ( $ id ) ; $ model -> setScenario ( 'update' ) ; Yii :: $ app -> response -> format = Response :: FORMAT_HTML ; return $ this -> renderAjax ( '@vendor/frenzelgmbh/cm-address/views/widgets/views/_form_update' , [ 'model' => $ model ] ) ; }
fetch Communication .
10,775
public function hotfixStart ( $ options = [ 'semversion' => null , 'type' => 'patch' ] ) { if ( empty ( $ options [ 'semversion' ] ) ) { $ version = $ this -> getVersion ( ) -> increment ( $ options [ 'type' ] ) ; } else { $ version = $ options [ 'semversion' ] ; } return $ this -> taskHotfixStart ( ( string ) $ versio...
Start a new hotfix
10,776
public function hotfixFinish ( $ options = [ 'semversion' => null , 'type' => 'patch' ] ) { if ( empty ( $ options [ 'semversion' ] ) ) { $ version = $ this -> getVersion ( ) -> increment ( $ options [ 'type' ] ) ; } else { $ version = $ options [ 'semversion' ] ; } return $ this -> taskHotfixFinish ( ( string ) $ vers...
Finish a hotfix
10,777
public function releaseStart ( $ options = [ 'semversion' => null , 'type' => 'minor' ] ) { if ( empty ( $ options [ 'semversion' ] ) ) { $ version = $ this -> getVersion ( ) -> increment ( $ options [ 'type' ] ) ; } else { $ version = $ options [ 'semversion' ] ; } return $ this -> taskReleaseStart ( ( string ) $ vers...
Start a new release
10,778
public function releaseFinish ( $ options = [ 'semversion' => null , 'type' => 'minor' ] ) { if ( empty ( $ options [ 'semversion' ] ) ) { $ version = $ this -> getVersion ( ) -> increment ( $ options [ 'type' ] ) ; } else { $ version = $ options [ 'semversion' ] ; } return $ this -> taskReleaseFinish ( ( string ) $ ve...
Finish a release
10,779
protected function getVersion ( ) { $ cmd = new Command ( 'git' ) ; $ cmd = $ cmd -> arg ( 'tag' ) -> execute ( ) ; $ output = explode ( PHP_EOL , trim ( $ cmd -> getOutput ( ) ) ) ; $ currentVersion = '0.0.0' ; foreach ( $ output as $ tag ) { if ( preg_match ( SemanticVersion :: REGEX , $ tag ) ) { if ( version_compar...
Return current version
10,780
protected function getAvailableHandle ( ) { foreach ( $ this -> handles as $ h ) { if ( ! in_array ( $ h , $ this -> groups , true ) ) { return $ h ; } } $ handle = new CurlMulti ( ) ; $ handle -> setEventDispatcher ( $ this -> getEventDispatcher ( ) ) ; $ this -> handles [ ] = $ handle ; return $ handle ; }
Get an existing available CurlMulti handle or create a new one
10,781
public static function getConfiguration ( string $ input ) { list ( $ oldrev , $ newrev , $ refname ) = explode ( ' ' , $ input ) ; list ( , , $ branch ) = explode ( '/' , $ refname ) ; return new ParserVariableConfiguration ( $ oldrev , $ newrev , $ refname , $ branch ) ; }
Extracts data from the post - receive hook as configuration for easy use .
10,782
public static function getEnvironmentVariables ( ) { $ dir = shell_exec ( 'pwd' ) ; $ dir_parts = explode ( DIRECTORY_SEPARATOR , $ dir ) ; $ project = trim ( array_pop ( $ dir_parts ) ) ; $ client = trim ( array_pop ( $ dir_parts ) ) ; $ dir = $ dir . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY...
Bootstraps the environment variables .
10,783
public static function collectServices ( ContainerBuilder $ container , \ Traversable $ namespaces ) { $ service_directories = [ ] ; foreach ( $ namespaces as $ directory ) { $ service_directories [ ] = $ directory . DIRECTORY_SEPARATOR . '..' ; } $ loader = new PhpFileLoader ( $ container , new FileLocator ( $ service...
Iterate through all namespace dirs and add services to the container .
10,784
public static function getValidParsers ( ProjectTypeInterface $ project , ParserDictionary $ parserDictionary , EventDispatcherInterface $ dispatcher ) { $ parserSet = $ project :: getFileParsers ( $ parserDictionary ) ; $ event = new ParserSetEvent ( $ project , $ parserSet ) ; $ dispatcher -> dispatch ( ProjectTypeIn...
Gets an array of valid parser plugins for the project type .
10,785
public function offsetSet ( $ offset , $ value ) { if ( is_null ( $ offset ) ) { throw new \ Exception ( 'Must supply key to modify an associative array.' ) ; } else { if ( $ this -> _isFillable ( $ offset ) ) { $ this -> _args [ $ offset ] = $ value ; } else { throw new \ Exception ( 'Cannot modify element \'' . $ off...
Override the offsetSet function to enforce the list of restricted keys .
10,786
public function setSeedQuery ( $ key , $ value ) { $ index = $ this -> getSeedQueryIndex ( ) ; $ this -> seedQueries [ $ index ] [ $ key ] = $ value ; }
The stter for the seed queries class property .
10,787
protected function getWordpressDatabaseInstance ( ) { global $ wpdb ; if ( ( ! \ class_exists ( 'wpdb' ) ) || ( ! $ wpdb ) || ( ! $ wpdb instanceof \ wpdb ) ) { throw InvalidDatabaseInstanceException :: wordpressDatabaseIsNotSet ( ) ; } $ this -> db = $ wpdb ; }
Tightly coupled to the wordpress database instance .
10,788
public function table ( $ name , $ callback = null ) { if ( ! $ callback instanceof \ Closure ) { throw InvalidArgumentPassedException :: isNotClosure ( ) ; } $ this -> setTableName ( $ name ) ; $ callback ( $ this ) ; $ tableNamePrefixed = $ this -> getTableNamePrefix ( $ this -> getTableName ( ) ) ; $ tableStructure ...
The composer of the database table schema .
10,789
protected function buildCreateTableQuery ( $ name , $ struture , $ charsetCollate ) { $ total = $ this -> totalQueries ( ) ; $ this -> queries [ $ total ] = "CREATE TABLE `{$name}` ({$struture}) {$charsetCollate};" ; }
Build a create table query base on the complete details given .
10,790
public function tableSeed ( $ tableName , $ callback ) { if ( ! is_array ( $ callback ) && ! ( $ callback instanceof \ Closure ) ) { throw InvalidArgumentPassedException :: isNotArrayOrClosure ( ) ; } $ this -> setTableName ( $ tableName ) ; $ this -> flushSeedQueryIndex ( ) ; if ( $ callback instanceof \ Closure ) { $...
The composer for seeding the given table name .
10,791
public function iterate ( $ counter ) { if ( ! \ is_numeric ( $ counter ) ) { throw InvalidArgumentPassedException :: isNotNumeric ( ) ; } $ this -> setSeedQuery ( 'iterate' , \ round ( $ counter ) ) ; }
The repetition that will apply for the given record .
10,792
public function rawQuery ( $ query = '' ) { if ( ! \ is_string ( $ query ) ) { throw InvalidArgumentPassedException :: isNotString ( ) ; } $ total = $ this -> totalQueries ( ) ; $ this -> queries [ $ total ] = \ trim ( $ query ) ; }
Allow to compose raw database query .
10,793
protected function processQueries ( ) { if ( ! \ function_exists ( 'dbDelta' ) ) { throw WPDatabaseUpdateFunctionsNotFoundException :: dbDeltaIsNotExist ( ) ; } $ queries = '' ; foreach ( $ this -> getQueries ( ) as $ index => $ query ) { $ queries .= \ trim ( $ query ) ; } \ dbDelta ( $ queries ) ; }
Process the queries using the wordpress dbDelta . This function is tightly coupled to the wordpress dbDelta .
10,794
protected function processTableSeeds ( ) { foreach ( $ this -> getSeedQueries ( ) as $ index => $ query ) { if ( isset ( $ query [ 'iterate' ] ) ) { for ( $ x = 1 ; $ x <= $ query [ 'iterate' ] ; $ x ++ ) { $ this -> db -> insert ( $ query [ 'table' ] , $ query [ 'record' ] ) ; } continue ; } $ this -> db -> insert ( $...
Process the seed queries using the wordpress database insert .
10,795
public function dropTable ( $ tableName ) { $ this -> db -> query ( 'SET FOREIGN_KEY_CHECKS = 0;' ) ; $ this -> db -> query ( "DROP TABLE IF EXISTS `{$this->getTableNamePrefix($tableName)}`;" ) ; $ this -> db -> query ( 'SET FOREIGN_KEY_CHECKS = 1;' ) ; }
Process the drop table base on the given table name . Foreign key checks disable before processing the drop action and enable it back again after the process .
10,796
public static function encode ( $ data ) : string { if ( PHP_VERSION_ID >= 50400 ) { return json_encode ( $ data , JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) ; } return json_encode ( $ data ) ; }
encode data to json
10,797
public function parse ( ) { foreach ( $ this -> parser -> parse ( $ this -> inputFile ) as $ item ) { $ writer = WriterFactory :: create ( $ item [ 'type' ] , $ this -> config ) ; if ( $ writer ) { $ writer -> write ( $ item ) ; } } }
Calls the parser and generates the files
10,798
protected function registerEntityAuditConfigurations ( Repository $ config ) { $ this -> app -> afterResolving ( IlluminateRegistry :: class , function ( $ registry ) use ( $ config ) { $ table = $ config -> get ( 'entity_audit.global.table' ) ; $ users = $ config -> get ( 'entity_audit.global.username_for' ) ; $ colum...
Registers auditing to the specified entity managers
10,799
protected function parseConfigFiles ( Finder $ files ) { $ config = [ ] ; foreach ( $ files as $ file ) { $ path = $ file -> getRealPath ( ) ; if ( ! file_exists ( dirname ( $ path ) . '/RoboFile.php' ) ) { continue ; } $ this -> printTaskInfo ( sprintf ( 'Parsing config from %s.' , $ path ) ) ; $ contents = file_get_c...
Helper function to parse config files .