idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
15,500
public static function SetAuthors ( $ authors ) { self :: CheckBackend ( ) ; $ authors = trim ( $ authors ) ; $ authors = trim ( $ authors , "," ) ; self :: $ backend -> Set ( "authors" , $ authors ) ; }
Set the authors of the extension . This should be a comma seperated list with the names of the authors .
15,501
public static function SetContributors ( $ contributors ) { self :: CheckBackend ( ) ; $ contributors = trim ( $ contributors ) ; $ contributors = trim ( $ contributors , "," ) ; self :: $ backend -> Set ( "contributors" , $ contributors ) ; }
Set the contributors of the extension . This should be a comma seperated list with the names of the contributors .
15,502
public static function SetExtensionName ( $ name ) { self :: CheckBackend ( ) ; $ name = trim ( $ name ) ; self :: $ backend -> Set ( "name" , $ name ) ; }
Set the extension name which is used in some important parts of the code generator .
15,503
public static function SetVersion ( $ number ) { self :: CheckBackend ( ) ; $ number = trim ( $ number ) ; self :: $ backend -> Set ( "version" , $ number ) ; }
Sets the version of the extension which is used in some important parts of the code generator .
15,504
public function redirect ( $ provider ) { $ this -> getProviderDetails ( $ provider ) ; return Socialite :: driver ( $ this -> provider -> driver ) -> scopes ( $ this -> provider -> scopes ) -> with ( $ this -> provider -> extras ) -> redirect ( ) ; }
Redirect the user based on the social provider being used .
15,505
public function socialUpdate ( $ provider , User $ user ) { $ this -> getProviderDetails ( $ provider ) ; $ socialUser = $ this -> getSocialUser ( ) ; $ this -> updateFromProvider ( $ user , $ socialUser ) ; return $ socialUser ; }
Update a user s social details fore a given provider .
15,506
protected function getUser ( $ socialUser ) { $ user = $ this -> users -> where ( 'email' , $ socialUser -> getEmail ( ) ) -> orWhereHas ( 'socials' , function ( $ query ) use ( $ socialUser ) { $ query -> where ( 'email' , $ socialUser -> getEmail ( ) ) -> where ( 'provider' , $ this -> provider -> driver ) ; } ) -> f...
Make sure that we have a valid user to work with .
15,507
protected function updateFromProvider ( $ user , $ socialUser ) { if ( ! $ user -> hasProvider ( $ this -> provider -> driver ) ) { return $ user -> addSocial ( $ socialUser , $ this -> provider -> driver ) ; } return $ user -> getProvider ( $ this -> provider -> driver ) -> updateFromProvider ( $ socialUser , $ this -...
Either update an existing provider record with the newest details or add this provider to the user .
15,508
private function getProvider ( $ providerName ) { $ provider = is_null ( $ providerName ) ? $ this -> providers -> first ( ) : $ this -> providers -> get ( $ providerName ) ; return $ this -> provider = new Provider ( $ provider ) ; }
Get the provider from the supplied name .
15,509
private function isEndToken ( ) { return $ this -> tokenIs ( ';' ) || $ this -> tokenIs ( ',' ) || $ this -> tokenIs ( ')' ) || $ this -> tokenIs ( ']' ) || $ this -> tokenIs ( T_DOUBLE_ARROW ) ; }
Check if the current token is a ending token .
15,510
public function getValue ( ) { if ( ! ( is_array ( $ this -> data ) && count ( $ this -> data ) ) ) { return null ; } return implode ( '' , $ this -> data ) ; }
Retrieve the value of the string parser .
15,511
public function getAttributesString ( array $ skip = [ ] ) : string { $ skip = array_map ( 'strtolower' , $ skip ) ; $ res = [ ] ; if ( $ this -> id ) { $ res [ ] = 'id="' . htmlspecialchars ( ( string ) $ this -> getId ( ) , ENT_QUOTES ) . '"' ; } foreach ( $ this -> attributes as $ k => $ v ) { if ( in_array ( $ k , ...
Return string consisting from all html element attributes
15,512
public function setWidget ( Widget $ widget ) { $ this -> widget = $ widget ; $ this -> widget -> setOwner ( $ this ) ; return $ this ; }
Set Widget button near element field
15,513
public function enableGoogleMap ( $ options = [ ] ) { $ widget = GoogleMap :: getInstance ( ) ; $ widget -> options = $ options ; $ this -> setWidget ( $ widget ) ; PageHead :: getInstance ( ) -> addJsUrl ( 'https://maps.googleapis.com/maps/api/js?key=' . Settings :: get ( 'google_api_key' ) ) ; return $ this ; }
Enables google map place picker
15,514
public function enableCalendarDatepicker ( ) { if ( ! $ this -> isEnabledCalendarDatepicker ( ) ) { PageTail :: getInstance ( ) -> addCssUrl ( 'plugins/datepicker/datepicker.css' ) -> addJsUrl ( 'plugins/datepicker/bootstrap-datepicker.js' ) ; $ this -> setDateFormat ( 'yyyy-mm-dd' ) ; } $ this -> calendar_datepicker_e...
Enables simple datepicker for input
15,515
public function enableDateTimePicker ( $ options = [ ] ) { if ( ! $ this -> isEnabledDateTimePicker ( ) ) { PageTail :: getInstance ( ) -> addCssUrl ( 'plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css' ) -> addJsUrl ( 'plugins/moment/js/moment.min.js' ) -> addJsUrl ( 'plugins/bootstrap-datetimepick...
Enable Bootstrap DateTimePicker on input
15,516
public function enableMiniColors ( $ options = [ ] ) { if ( ! $ this -> isEnabledMiniColors ( ) ) { PageTail :: getInstance ( ) -> addCssUrl ( 'plugins/minicolors/jquery.minicolors.css' ) -> addJsUrl ( 'plugins/minicolors/jquery.minicolors.min.js' ) ; } if ( ! isset ( $ options [ 'control' ] ) ) { $ options [ 'control'...
Enable MiniColors on input
15,517
public function validateRequired ( ) { $ this -> validator_attributes [ ] = 'data-parsley-required' ; $ this -> field_required = true ; $ this -> validator_checks [ 'required' ] = true ; return $ this ; }
Validate that a required field has been filled with a non blank value Set field as required to fill
15,518
public function validateMinLength ( $ length ) { $ this -> validator_attributes [ ] = 'data-parsley-minlength="' . ( int ) $ length . '"' ; $ this -> validator_checks [ 'min_length' ] = ( int ) $ length ; return $ this ; }
Validates that the length of a string is at least as long as the given limit .
15,519
public function validateMaxLength ( $ length ) { $ this -> validator_attributes [ ] = 'data-parsley-maxlength="' . ( int ) $ length . '"' ; $ this -> validator_checks [ 'max_length' ] = ( int ) $ length ; return $ this ; }
Validates that the length of a string is not larger than the given limit .
15,520
public function validateLength ( $ min_length , $ max_length ) { $ this -> validator_attributes [ ] = 'data-parsley-length="[' . ( int ) $ min_length . ', ' . ( int ) $ max_length . ']"' ; $ this -> validator_checks [ 'min_length' ] = ( int ) $ min_length ; $ this -> validator_checks [ 'max_length' ] = ( int ) $ max_le...
Validates that a given string length is between some minimum and maximum value .
15,521
public function validateMin ( $ amount ) { $ this -> validator_attributes [ ] = 'data-parsley-min="' . ( float ) $ amount . '"' ; $ this -> validator_checks [ 'min' ] = ( float ) $ amount ; return $ this ; }
Validates that a given number is greater than or equal to some minimum number .
15,522
public function validateMax ( $ amount ) { $ this -> validator_attributes [ ] = 'data-parsley-max="' . ( float ) $ amount . '"' ; $ this -> validator_checks [ 'max' ] = ( float ) $ amount ; return $ this ; }
Validates that a given number is less than or equal to some maximum number .
15,523
public function validateRange ( $ min_amount , $ max_amount ) { $ this -> validator_attributes [ ] = 'data-parsley-range="[' . ( float ) $ min_amount . ', ' . ( float ) $ max_amount . ']"' ; $ this -> validator_checks [ 'min' ] = ( float ) $ min_amount ; $ this -> validator_checks [ 'max' ] = ( float ) $ max_amount ; r...
Validates that a given number is between some minimum and maximum number .
15,524
public function validateMinCheckboxesChecked ( $ count ) { $ this -> validator_attributes [ ] = 'data-parsley-mincheck="' . ( int ) $ count . '"' ; $ this -> validator_checks [ 'min_checkboxes_checked' ] = ( int ) $ count ; return $ this ; }
Validates that a certain minimum number of checkboxes in a group are checked .
15,525
public function validateMaxCheckboxesChecked ( $ count ) { $ this -> validator_attributes [ ] = 'data-parsley-maxcheck="' . ( int ) $ count . '"' ; $ this -> validator_checks [ 'max_checkboxes_checked' ] = ( int ) $ count ; return $ this ; }
Validates that a certain maximum number of checkboxes in a group are checked .
15,526
public function validateRangeCheckboxesChecked ( $ min_count , $ max_count ) { $ this -> validator_attributes [ ] = 'data-parsley-check="[' . ( int ) $ min_count . ', ' . ( int ) $ max_count . ']"' ; $ this -> validator_checks [ 'min_checkboxes_checked' ] = ( int ) $ min_count ; $ this -> validator_checks [ 'max_checkb...
Validates that the number of checked checkboxes in a group is within a certain range .
15,527
public function onBefore ( BeforeEvent $ event ) { $ now = new \ DateTime ; $ createdAt = $ now -> format ( $ this -> getDateFormat ( ) ) ; $ request = $ event -> getRequest ( ) ; $ nonce = call_user_func ( $ this -> getNonce ( ) , $ request ) ; $ password = $ this -> passwordProcessor ? call_user_func ( $ this -> pass...
On before event handler
15,528
public function createWsseHeader ( $ username , $ digest , $ nonce , $ createdAt ) { return sprintf ( 'UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"' , $ username , $ digest , base64_encode ( $ nonce ) , $ createdAt ) ; }
Create the WSSE header
15,529
public static function digest ( $ nonce , $ createdAt , $ password ) { return base64_encode ( sha1 ( $ nonce . $ createdAt . $ password , true ) ) ; }
Create a password digest
15,530
public static function nonce ( RequestInterface $ request = null ) { $ url = $ request ? $ request -> getUrl ( ) : null ; return sha1 ( uniqid ( '' , true ) . $ url ) ; }
Generate a nonce
15,531
public function aroundUpdateStockItemBySku ( \ Magento \ CatalogInventory \ Model \ StockRegistry $ subject , \ Closure $ proceed , $ productSku , \ Magento \ CatalogInventory \ Api \ Data \ StockItemInterface $ stockItem ) { $ result = null ; $ stockId = $ stockItem -> getStockId ( ) ; if ( $ stockId ) { $ result = $ ...
Disable creation for default stock item on product save .
15,532
public function actionAddParam ( $ id = null , $ languageId = null ) { if ( \ Yii :: $ app -> user -> can ( 'updateProduct' , [ 'productOwner' => Product :: findOne ( $ id ) -> owner ] ) ) { $ param = new Param ( ) ; $ param -> product_id = $ id ; $ param_translation = new ParamTranslation ( ) ; $ param_translation -> ...
Adds params for product model .
15,533
public function actionDeleteParam ( $ id ) { $ param = Param :: findOne ( $ id ) ; $ param -> delete ( ) ; $ this -> trigger ( self :: EVENT_AFTER_EDIT_PRODUCT , new ProductEvent ( [ 'id' => $ param -> product_id ] ) ) ; return $ this -> redirect ( Yii :: $ app -> request -> referrer ) ; }
Deletes param from product model .
15,534
public function actionUpdateParam ( int $ id , int $ languageId ) { if ( ! empty ( $ id ) && ! empty ( $ languageId ) ) { $ paramTranslation = ParamTranslation :: find ( ) -> where ( [ 'param_id' => $ id , 'language_id' => $ languageId ] ) -> one ( ) ; if ( empty ( $ paramTranslation ) ) { $ paramTranslation = new Para...
Update param translation . Users which have updateOwnProduct permission can update params only for Product models that have been created by their . Users which have updateProduct permission can update params for all Product models .
15,535
public function hasScope ( string $ name , Member $ member ) : bool { return $ member -> Groups ( ) -> filter ( [ 'Scopes.Name' => $ name ] ) -> count ( ) > 0 ; }
Checks whether the member has the specified scope .
15,536
public function count ( ) { $ criteria = clone $ this -> getCriteria ( ) ; $ result = $ criteria -> limit ( 0 , 0 ) -> columns ( [ 'count' => 'COUNT(*)' ] ) -> findFirst ( ) ; return ( int ) $ result -> count ; }
Count the total items number
15,537
public function isInCurrentDocument ( ) { return ( $ this -> mergedUri -> getScheme ( ) === $ this -> originUri -> getScheme ( ) && $ this -> mergedUri -> getHost ( ) === $ this -> originUri -> getHost ( ) && $ this -> mergedUri -> getPort ( ) === $ this -> originUri -> getPort ( ) && $ this -> mergedUri -> getPath ( )...
Return true if reference and origin are in the same document
15,538
public function indexAction ( Template $ template ) { $ templating = $ this -> container -> get ( 'templating' ) ; $ response = $ this -> getResponse ( $ templating -> render ( $ template -> getRenderName ( ) , $ template -> getRenderData ( ) ) ) ; return ( $ response ) ; }
indexAction Render a template routed by the template matcher .
15,539
public function addParameter ( Parameter $ parameter ) { if ( array_key_exists ( $ parameter -> getName ( ) , $ this -> definitions ) ) { throw new \ Exception ( sprintf ( 'Parameter with name \'%s\' already exists!' , $ parameter -> getName ( ) ) ) ; } $ this -> definitions [ $ parameter -> getName ( ) ] = $ parameter...
Add a new parameter object to the definition
15,540
public function getByAttributes ( array $ attributes ) : ? Model { if ( empty ( $ attributes ) ) { return null ; } $ query = $ this -> getModel ( ) -> newQuery ( ) ; foreach ( $ attributes as $ key => $ value ) { $ query -> where ( $ key , $ value ) ; } return $ query -> first ( ) ; }
Retrieve a group by the given attributes .
15,541
private function updateRepr ( ) { $ this -> message = $ this -> rawMessage ; $ this -> message = strtr ( $ this -> message , [ '%item%' => $ this -> item , '%dependency%' => $ this -> dependency , ] ) ; }
Updates the message representation with the item and dependency .
15,542
protected function getConfigValue ( $ name ) { if ( substr ( $ name , 0 , 1 ) != '/' ) { $ name = '/' . $ name ; } $ config = new JsonConfig ( getcwd ( ) . '/composer.json' ) ; $ value = $ config -> getConfigValue ( '/extra/contao' . $ name ) ; if ( $ value === null ) { $ config = $ this -> getApplication ( ) -> getCon...
Fetch some value from the config .
15,543
protected function checkValidSlug ( $ slug ) { if ( preg_match_all ( '#^([a-z,A-Z,0-9,\-,_]*)(.+)?$#' , $ slug , $ matches ) && ( strlen ( $ matches [ 2 ] [ 0 ] ) > 0 ) ) { throw new \ RuntimeException ( sprintf ( 'Error: prefix "%s" is invalid. It must only contain letters, numbers, underscores and hyphens. ' . 'Found...
Check that the passed project slug complies to the transifex restrictions .
15,544
protected function determineLanguages ( OutputInterface $ output , $ srcdir , $ filter = array ( ) ) { if ( ! is_dir ( $ srcdir ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The path %s does not exist.' , $ srcdir ) ) ; } $ this -> writelnVerbose ( $ output , sprintf ( '<info>scanning for languages in: %s</in...
Determine the list of languages .
15,545
private function setProject ( InputInterface $ input , OutputInterface $ output ) { $ this -> project = $ input -> getOption ( 'projectname' ) ; if ( ! $ this -> project ) { $ this -> project = $ this -> getTransifexConfigValue ( '/project' ) ; if ( ! $ this -> project ) { throw new \ RuntimeException ( 'Error: unable ...
Set the project either from command line parameter or from config .
15,546
private function setPrefix ( InputInterface $ input , OutputInterface $ output ) { $ this -> prefix = $ input -> getOption ( 'prefix' ) ; if ( $ this -> prefix === null ) { $ this -> prefix = $ this -> getTransifexConfigValue ( '/prefix' ) ; if ( $ this -> prefix === null ) { throw new \ RuntimeException ( 'Error: unab...
Set the prefix either from command line parameter or from config .
15,547
private function setXliffDirectory ( InputInterface $ input , OutputInterface $ output ) { $ this -> txlang = $ input -> getOption ( 'xliff' ) ; if ( $ this -> txlang === null ) { $ this -> txlang = $ this -> getTransifexConfigValue ( '/languages_tx' ) ; if ( $ this -> txlang === null ) { throw new \ RuntimeException (...
Set the xliff directory either from command line parameter or from config .
15,548
private function setContaoLanguageDirectory ( InputInterface $ input , OutputInterface $ output ) { $ this -> ctolang = $ input -> getOption ( 'contao' ) ; if ( $ this -> ctolang === null ) { $ this -> ctolang = $ this -> getTransifexConfigValue ( '/languages_cto' ) ; if ( $ this -> ctolang === null ) { throw new \ Run...
Set the contao language file directory either from command line parameter or from config .
15,549
public function move_admin_bar_inline_styles ( ) { if ( ! is_admin ( ) ) { $ this -> remove_action ( 'wp_head' , '_admin_bar_bump_cb' ) ; $ this -> remove_action ( 'wp_head' , 'wp_admin_bar_header' ) ; $ this -> add_action ( 'wp_footer' , 'wp_admin_bar_header' ) ; $ this -> add_action ( 'wp_footer' , '_admin_bar_bump_c...
Move all frontend admin bar css and js to footer .
15,550
public function clean_asset_tags ( $ tag ) { \ preg_match_all ( "!<link rel='stylesheet'\s?(id='[^']+')?\s+href='(.*)' type='text/css' media='(.*)' />!" , $ tag , $ matches ) ; if ( empty ( $ matches [ 2 ] ) ) { return $ tag ; } $ media = $ matches [ 3 ] [ 0 ] !== '' && $ matches [ 3 ] [ 0 ] !== 'all' ? ' media="' . $ ...
Remove un needed attributes from asset tags .
15,551
private function remove_emojis ( ) { $ this -> remove_hook ( [ 'the_content_feed' , 'comment_text_rss' ] , 'wp_staticize_emoji' ) ; $ this -> remove_hook ( 'wp_head' , 'print_emoji_detection_script' , 7 ) ; $ this -> remove_hook ( 'wp_mail' , 'wp_staticize_emoji_for_email' ) ; $ this -> remove_hook ( 'admin_print_scrip...
Remove emoji js and css site - wide .
15,552
public function enqueueScript ( $ options ) { add_action ( 'wp_ajax_' . $ options [ 'name' ] , [ & $ this , 'hookCallback' ] ) ; add_action ( 'wp_ajax_nopriv_' . $ options [ 'name' ] , [ & $ this , 'hookCallback' ] ) ; wp_localize_script ( $ options [ 'handle' ] , $ options [ 'name' ] , $ options [ 'args' ] ) ; }
Hooks and enqueue script .
15,553
public function hookCallback ( ) { $ name = $ this -> getModel ( ) -> getName ( ) ; check_ajax_referer ( $ name , 'nonce' ) ; $ data = $ this -> callback ( ) ; wp_send_json_success ( $ data ) ; wp_die ( ) ; }
Hook callback method .
15,554
protected function validateNodeType ( string $ nodeType ) : string { if ( ! in_array ( $ nodeType , static :: $ validNodeTypes ) ) { throw new \ InvalidArgumentException ( "invalid value node type '$nodeType'; expecting " . \ sndsgd \ Arr :: implode ( ", " , static :: $ validNodeTypes , "or " ) ) ; } return $ nodeType ...
Verify a node type is valid
15,555
public function isProd ( ) : bool { $ nodeType = $ this -> isEmulated ( ) ? $ this -> emulatedNodeType : $ this -> nodeType ; return ( $ nodeType === self :: PROD || $ nodeType === self :: STAGE ) ; }
Determine whether the current environment is production
15,556
public static function mock ( array $ stack = [ ] ) : ApiClient { $ mock = new MockHandler ( $ stack ) ; $ handler = HandlerStack :: create ( $ mock ) ; $ client = new Client ( [ 'handler' => $ handler , 'verify' => false ] ) ; app ( ) -> instance ( 'ej:sdk:guzzle' , $ client ) ; return resolve ( __CLASS__ ) ; }
Mocks a response stack into the api client
15,557
public function resource ( string $ resourceName ) : Repository { if ( $ resource = $ this -> resources -> get ( $ resourceName ) ) { return ResourceCollection :: makeResourceRepository ( $ resource ) ; } throw new Exception ( "Invalid api resource repository '{$resourceName}'" ) ; }
Resource repository accessor
15,558
public function send ( ) { if ( $ this -> attachments ) { $ this -> prepareWithAttachments ( ) ; } else { $ this -> addHeader ( 'Content-Type: ' . $ this -> content_type . '; charset=utf-8' ) ; $ this -> message_body = $ this -> message ; } if ( $ this -> sender_email ) { $ this -> addHeader ( 'From: "' . $ this -> mai...
Prepares all headers and sends email
15,559
public static function createByFilePath ( $ filepath ) : Repository { $ filename = basename ( $ filepath ) ; list ( $ domain , $ language , $ extension ) = explode ( '.' , $ filename , 3 ) ; $ yamlParser = new YamlParser ( ) ; $ data = $ yamlParser -> parse ( file_get_contents ( $ filepath ) ) ; $ emptyArray = [ ] ; $ ...
Create a new repository given a file path .
15,560
public static function createEmptyByFilePath ( string $ filepath ) : Repository { $ filename = basename ( $ filepath ) ; list ( $ domain , $ language , $ extension ) = explode ( '.' , $ filename , 3 ) ; return new self ( TranslationCollection :: create ( [ ] ) , $ filepath , $ language , $ domain ) ; }
Create empty repository given it s path .
15,561
private static function createPlainRepresentationByArray ( array & $ translations , string $ language , array $ data , array $ structure , string $ prefix ) { foreach ( $ data as $ key => $ value ) { $ currentStructure = $ structure ; if ( is_array ( $ value ) ) { $ emptyArray = [ ] ; self :: appendValueIntoStructure (...
Given an array return a list of plain keys and values .
15,562
public function buildPath ( ) : string { return self :: buildRepositoryPath ( dirname ( $ this -> path ) , $ this -> domain , $ this -> language ) ; }
Get Path .
15,563
public function save ( ) { $ translationStructure = [ ] ; foreach ( $ this -> getTranslations ( ) as $ translation ) { $ translationStructure = array_merge_recursive ( $ translationStructure , $ translation -> getStructure ( ) ) ; } $ dumper = new YamlDumper ( ) ; $ yaml = $ dumper -> dump ( $ translationStructure , 10...
Save structure .
15,564
public static function buildRepositoryPath ( string $ basename , string $ domain , string $ language ) : string { return sprintf ( '%s/%s.%s.yml' , $ basename , $ domain , $ language ) ; }
Build the repository path given the basename the domain and the language .
15,565
protected function isRoutableTemplate ( Template $ template ) { $ template_file = new \ SplFileInfo ( $ template -> getFilename ( ) ) ; $ is_routable = ( $ this -> unroutablePrefix !== substr ( $ template_file -> getBasename ( ) , 0 , strlen ( $ this -> unroutablePrefix ) ) ) ; return ( $ is_routable ) ; }
isRoutableTemplate Determine if the template from the resolver should be routed .
15,566
public function setApplicationId ( $ objectOrId ) { if ( $ objectOrId instanceof Application ) { $ objectOrId = $ objectOrId -> getId ( ) ; } $ this -> setValue ( 'application' , ( string ) $ objectOrId ) ; }
Set Application identifier that contains this item .
15,567
public function setPrototypeId ( $ objectOrId ) { if ( $ objectOrId instanceof Prototype ) { $ objectOrId = $ objectOrId -> getId ( ) ; } $ this -> setValue ( 'prototypeId' , ( string ) $ objectOrId ) ; }
Set Item prototype identifier .
15,568
public function getCreator ( ) { return $ this -> getCachedProperty ( 'creator' , function ( ) { try { return $ this -> getValue ( 'creator' ) ? new Account ( $ this -> getValue ( 'creator' ) ) : null ; } catch ( \ InvalidArgumentException $ e ) { throw new \ UnexpectedValueException ( $ e -> getMessage ( ) , $ e -> ge...
Return Item creator .
15,569
public function setCreator ( $ objectOrId ) { $ this -> dropCachedProperty ( 'creator' ) ; if ( ! $ objectOrId instanceof Account ) { $ objectOrId = new Account ( [ 'id' => $ objectOrId ] ) ; } $ this -> setValue ( 'creator' , $ objectOrId -> export ( ) ) ; }
Set Item creator .
15,570
public function setUpdatedAt ( $ time ) { if ( $ time instanceof \ DateTimeInterface ) { $ time = $ time -> format ( DATE_RFC3339 ) ; } $ this -> setValue ( 'lastModified' , ( string ) $ time ) ; }
Set modification date and time .
15,571
public function getProperties ( ) { $ names = array_keys ( $ this -> getValue ( 'properties' ) ) ; $ result = [ ] ; foreach ( $ names as $ name ) { $ result [ $ name ] = $ this -> get ( $ name ) ; } return $ result ; }
Return all properties as associative array .
15,572
public function get ( $ property , $ default = null ) { $ properties = $ this -> getValue ( 'properties' , [ ] ) ; if ( array_key_exists ( $ property , $ properties ) ) { $ value = $ properties [ $ property ] ; if ( is_array ( $ value ) ) { $ value = reset ( $ value ) ; } return $ value ; } return $ default ; }
Return Item property .
15,573
public function set ( $ property , $ value ) { $ properties = $ this -> getValue ( 'properties' , [ ] ) ; $ properties [ $ property ] = [ $ value ] ; $ this -> setValue ( 'properties' , $ properties ) ; }
Set Item property value .
15,574
public function find ( $ id ) { $ attributes = $ this -> backend -> find ( $ id ) ; if ( ! is_null ( $ attributes ) ) { return $ this -> deserializeEntry ( $ attributes ) ; } }
Find a specific entry in the schedule
15,575
public function schedule ( Job $ job , $ minute = null , $ hour = null , $ dayOfMonth = null , $ month = null , $ dayOfWeek = null ) { $ attributes = $ this -> backend -> schedule ( $ this -> serializeJob ( $ job ) , $ minute , $ hour , $ dayOfMonth , $ month , $ dayOfWeek ) ; return $ this -> deserializeEntry ( $ attr...
Schedule a job .
15,576
public function getJobsFor ( \ DateTime $ dateTime , $ lock = true ) { $ dateTime -> setTime ( $ dateTime -> format ( "H" ) , $ dateTime -> format ( "i" ) , 0 ) ; $ serializedJobs = $ this -> backend -> getJobsFor ( $ dateTime , $ lock ) ; $ jobs = array ( ) ; foreach ( $ serializedJobs as $ job ) { $ jobs [ ] = $ this...
Get jobs scheduled for the given DateTime .
15,577
public function listen ( $ event , $ listener ) { $ listers_of_event = isset ( $ this -> listeners [ $ event ] ) ? $ this -> listeners [ $ event ] : array ( ) ; if ( ! in_array ( $ listener , $ listers_of_event , true ) ) { $ listers_of_event [ ] = $ listener ; $ this -> listeners [ $ event ] = $ listers_of_event ; } }
add a listener callback to event emitter
15,578
public function unlisten ( $ event = null , $ listener = null ) { if ( $ event === null ) { $ this -> listeners = null ; return ; } if ( ! $ listener ) { unset ( $ this -> listeners [ $ event ] ) ; return ; } $ listers_of_event = isset ( $ this -> listeners [ $ event ] ) ? $ this -> listeners [ $ event ] : null ; if ( ...
remove a listener callback from event emitter
15,579
public static function GetDirContent ( $ path ) { $ files = array ( ) ; $ directory = opendir ( $ path ) ; while ( ( $ file = readdir ( $ directory ) ) !== false ) { $ full_path = $ path . "/" . $ file ; if ( is_file ( $ full_path ) ) { $ files [ ] = $ full_path ; } elseif ( $ file != "." && $ file != ".." && is_dir ( ...
Get all the files and directories available on a specified path .
15,580
public static function RecursiveCopyDir ( $ source , $ target ) { $ source_dir = opendir ( $ source ) ; if ( ! $ source_dir ) { return false ; } if ( ! file_exists ( $ target ) ) { self :: MakeDir ( $ target , 0755 , true ) ; } while ( ( $ item = readdir ( $ source_dir ) ) !== false ) { $ source_full_path = $ source . ...
Copy a directory and its content to another directory replacing any file on the target directory if already exist .
15,581
public static function RecursiveRemoveDir ( $ directory , $ empty = false ) { if ( substr ( $ directory , - 1 ) == '/' ) { $ directory = substr ( $ directory , 0 , - 1 ) ; } if ( ! file_exists ( $ directory ) || ! is_dir ( $ directory ) ) { return false ; } elseif ( ! is_readable ( $ directory ) ) { return false ; } el...
Remove a directory that is not empty by deleting all its content .
15,582
public static function WriteFileIfDifferent ( $ file , & $ content ) { $ actual_file_content = "" ; if ( file_exists ( $ file ) ) $ actual_file_content = file_get_contents ( $ file ) ; if ( crc32 ( $ actual_file_content ) != crc32 ( $ content ) ) { file_put_contents ( $ file , $ content ) ; return true ; } print false ...
Only saves content to a file if the new content is not the same as the original . This is helpful to prevent an unneccesary timestamp modification which is used by compilers to decide wether the file needs recompilation .
15,583
public function enqueue ( $ main ) { wp_enqueue_script ( 'wpmvc-updater' , addon_assets_url ( 'js/updater.js' , __FILE__ ) , [ 'jquery' ] , $ main -> config -> get ( 'version' ) , true ) ; wp_enqueue_style ( 'wpmvc-updater' , addon_assets_url ( 'css/updater.css' , __FILE__ ) , [ ] , $ main -> config -> get ( 'version' ...
Enqueues assets . Action admin_enqueue_scripts . Wordpress hook .
15,584
public function call ( ) { switch ( Request :: input ( 'do' , false ) ) { case 'init' : return $ this -> init ( ) ; case 'finish' : return $ this -> finish ( ) ; case 'notify' : return $ this -> notify ( ) ; } }
Routes request . Action wp_ajax_wpmvc_updater . Wordpress hook .
15,585
public function finish ( ) { $ response = new Response ; try { $ file = File :: auth ( ) ; if ( $ file -> exists ( self :: FILENAME ) ) unlink ( self :: FILENAME ) ; $ response -> success = true ; } catch ( Exception $ e ) { Log :: error ( $ e ) ; } $ response -> json ( ) ; }
Removes updater from Wordpress .
15,586
protected function init ( ) { $ errorMask = E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_PARSE | E_USER_ERROR | E_RECOVERABLE_ERROR ; set_error_handler ( function ( $ type , $ message , $ file , $ line ) use ( $ errorMask ) { $ this -> errors [ ] = [ 'type' => $ type , 'message' => $ message , 'file' => $ file , 'line'...
Init the collector
15,587
protected function handleIcon ( Infoset $ info ) { if ( empty ( $ this -> errors ) ) { $ info -> setIcon ( 'ok' ) ; return ; } if ( $ this -> hasError ) { $ info -> setIcon ( 'alert' ) ; return ; } $ info -> setIcon ( 'warning' ) ; }
Handle the iconn
15,588
public function isValidDelivery ( Country $ country ) { return $ this -> getRequest ( ) -> getSession ( ) -> getSessionCart ( $ this -> getDispatcher ( ) ) -> isVirtual ( ) ; }
The module is valid if the cart contains only virtual products .
15,589
public function setHeader ( $ header , $ value ) { $ value = ! is_array ( $ value ) ? array ( $ value ) : array_map ( 'trim' , $ value ) ; $ name = strtolower ( $ header ) ; $ this -> headers [ $ name ] = $ value ; foreach ( array_keys ( $ this -> headerLines ) as $ key ) if ( strtolower ( $ key ) == $ name ) unset ( $...
Set header as if it s new
15,590
public function getLastLogin ( ) : Carbon { if ( $ this -> lastLoginParsed !== null ) { return $ this -> lastLoginParsed ; } $ name = $ this -> getLastLoginKey ( ) ; $ lastLogin = $ this -> asDateTime ( $ this -> getAttributeFromArray ( $ name ) ?? Carbon :: now ( ) ) ; return $ this -> { $ name } = $ this -> lastLogin...
Get last login
15,591
public function updateLastLogin ( ? Carbon $ override = null ) { $ name = $ this -> getLastLoginKey ( ) ; if ( $ this -> getAttributeFromArray ( $ name ) === null ) { throw new NullValueException ( "Property {$name} not set on this object" ) ; } $ this -> { $ name } = $ override === null ? Carbon :: now ( ) -> toDateTi...
Update a users last login
15,592
public static function outputDebugStackTable ( ) { self :: prepareTraceStack ( ) ; if ( IS_CLI || IS_AJAX_REQUEST ) { foreach ( self :: $ trace_stack as $ step ) { echo 'Class: ' . ( isset ( $ step [ 'class' ] ) ? $ step [ 'class' ] . $ step [ 'type' ] : '' ) . $ step [ 'function' ] . '<br>' ; echo "\n" ; echo 'File: '...
Shows error alert and goes back
15,593
public static function error ( string $ str ) { if ( SELF === REF ) { throw new \ RuntimeException ( 'Looping references' ) ; } if ( IS_AJAX_REQUEST ) { echo $ str ; } else { ?> <script type="text/javascript">alert(' <?= $ str ?> '); if (history.length) { // Go back ...
Shows Javascript error alert
15,594
public static function ErrorHandlerHTML ( $ e_no , string $ e_str , string $ e_file , string $ e_line ) { $ e_str = strpos ( $ e_str , ':::' ) === false ? [ '' , $ e_str ] : explode ( ':::' , $ e_str ) ; if ( IS_CLI || IS_AJAX_REQUEST ) { echo self :: getErrorTextByNumber ( $ e_no ) . "\n" ; if ( $ e_str [ 0 ] === 'sql...
Plain text for terminals and error logs
15,595
public static function sendErrorToDevelopers ( $ title , $ msg , $ flag_file = '' ) { $ cfg_email = Configuration :: getInstance ( ) -> get ( 'site' ) [ 'email' ] ; if ( ! $ flag_file ) { $ flag_file = md5 ( $ msg ) ; } FileSystem :: mkDir ( DIR_CACHE . 'errors/' ) ; $ file = DIR_CACHE . 'errors/' . $ flag_file ; if ( ...
Sends error report to developers when error occurs
15,596
public static function get_nav_menu ( $ theme_location = 'primary' ) { $ menu = [ ] ; $ term = static :: get_menu_object ( $ theme_location ) ; if ( $ term !== false ) { $ menu_items_raw = \ wp_get_nav_menu_items ( $ term -> term_id ) ; $ menu_items = new Collection ( $ menu_items_raw ) ; $ custom_classes = $ menu_item...
Returns a multi dimensional array of nav items for a given navigation menu .
15,597
public static function get_menu_object ( $ theme_location ) { $ locations = \ get_nav_menu_locations ( ) ; if ( isset ( $ locations [ $ theme_location ] ) ) { return \ wp_get_nav_menu_object ( $ locations [ $ theme_location ] ) ; } return false ; }
Returns a menu object for a given theme location .
15,598
public static function get_menu_name ( $ theme_location ) { $ menu_obj = static :: get_menu_object ( $ theme_location ) ; if ( $ menu_obj !== false ) { return $ menu_obj -> name ; } return false ; }
For a given menu ID name or slug return the user - set name for the associated menu .
15,599
public function loginAction ( ) { $ uri = new \ TYPO3 \ Flow \ Http \ Uri ( 'https://api.twitter.com/oauth/request_token' ) ; $ request = \ TYPO3 \ Flow \ Http \ Request :: create ( $ uri , 'POST' ) ; $ request -> setContent ( '' ) ; $ callbackUri = $ this -> uriBuilder -> reset ( ) -> setCreateAbsoluteUri ( TRUE ) -> ...
Initializes the Twitter Authentication process . Will redirect to twitter for the user to login setting the oauth callback url to this controllers authenticate method .