idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
14,800
public static function schoolYearId ( $ grad = null ) { static :: loadData ( ) ; if ( $ grad == null ) { $ grad = static :: schoolYear ( ) ; } foreach ( static :: $ arrDBCalendar as $ sy ) { if ( date ( 'Y' , $ sy [ 'end' ] ) == $ grad ) return $ sy [ 'id' ] ; } return false ; }
Get id of current school year
14,801
public static function getCalRecurring ( $ strWeekdayAll , $ strWeekdayA , $ strWeekdayB , $ blnHolidays = false , $ schoolYearId = null ) { static :: loadData ( ) ; static :: generateFullCalendar ( 'all' ) ; $ arrCal = static :: $ arrFullCalendar [ $ schoolYearId ?? static :: schoolYearId ( ) ] ; $ arrDates = [ ] ; fo...
Find all dates of a weekly recurring event in the current school year
14,802
public static function getNextRecurring ( $ strWeekdayAll , $ strWeekdayA , $ strWeekdayB , $ blnHolidays = false ) { $ arrDates = static :: getCalRecurring ( $ strWeekdayAll , $ strWeekdayA , $ strWeekdayB , $ blnHolidays ) ; foreach ( $ arrDates as $ i => $ strDate ) { if ( time ( ) > strtotime ( $ arrDates [ $ i - 1...
Find next date for a weekly recurring event
14,803
protected function getParameter ( \ ReflectionParameter $ parameter ) { if ( $ parameter -> isOptional ( ) ) { return $ parameter -> getDefaultValue ( ) ; } $ type = ( string ) $ parameter -> getType ( ) ; return $ this -> get ( $ type ) ; }
Resolves a parameter for a function call .
14,804
protected function engineInfo ( Infoset $ info ) { $ engine = $ this -> createTable ( ) -> setColsWidths ( [ 1 , 99 ] ) -> enableBbCodes ( ) -> setTitle ( 'Engine' ) ; $ engine [ ] = [ 'PHP:' , '[success]' . phpversion ( ) . '[/success]' ] ; $ engine [ ] = [ 'Zend:' , '[success]' . zend_version ( ) . '[/success]' ] ; $...
Collect information about engine
14,805
protected function extensionsInfo ( Infoset $ info ) { $ extensions = $ this -> createTable ( ) -> setHeadContent ( [ 'Name' , 'Version' ] ) -> setColsWidths ( [ 1 , 99 ] ) -> enableBbCodes ( ) -> setTitle ( 'Extensions' ) ; $ info [ ] = $ extensions ; foreach ( get_loaded_extensions ( ) as $ extension ) { $ version = ...
Collect information about extensions
14,806
protected function opcacheInfo ( Infoset $ info ) { $ opconf = opcache_get_configuration ( ) ; $ config = $ opconf [ 'directives' ] ; $ list = $ this -> createDesclist ( ) -> enableBbCodes ( ) -> setTitle ( 'Zend OPcache ' . $ opconf [ 'version' ] [ 'version' ] ) ; $ info [ ] = $ list ; foreach ( self :: $ opcacheConfi...
Collect information about opcache
14,807
public function getParsedResponse ( ) { $ rawData = $ this -> bodyToArray ( ) ; if ( $ this -> responseWrapper instanceof Wrapper \ ResponseWrapperInterface ) { $ this -> responseWrapper -> init ( $ rawData , $ this ) ; return $ this -> responseWrapper ; } return $ rawData ; }
Returns a ResponseWrapperInterface instance
14,808
public function hashUserPasswordProperty ( ? int $ cost = null ) : string { if ( ! isset ( $ this -> password ) ) { throw new NullValueException ( 'Password property not set on this object' ) ; } return bcrypt ( $ this -> password , [ 'rounds' => $ this -> getPasswordCost ( $ cost ) ] ) ; }
Hash users password when property password is set
14,809
public function getPasswordCost ( ? int $ cost = null ) : int { if ( $ cost !== null ) { return $ cost ; } $ config = $ this -> config ?? config ( ) ; return $ config -> get ( 'laranixauth.password.cost' , 12 ) ; }
Get password cost
14,810
public static function contains ( string $ haystack , string $ needle , bool $ caseSensitive = true ) { if ( $ caseSensitive ) { return $ needle === '' || strpos ( $ haystack , $ needle ) !== false ; } return $ needle === '' || stripos ( $ haystack , $ needle ) !== false ; }
Return whether a term is in a string
14,811
public static function equals ( string $ string1 , string $ string2 , bool $ caseSensitive = true ) { if ( $ caseSensitive ) { return $ string1 === $ string2 ; } return strtolower ( $ string1 ) === strtolower ( $ string2 ) ; }
Compare two strings for identically
14,812
public static function startsWith ( string $ haystack , string $ needle , bool $ caseSensitive = true ) { if ( $ caseSensitive ) { return $ needle === '' || strpos ( $ haystack , $ needle ) === 0 ; } return $ needle === '' || stripos ( $ haystack , $ needle ) === 0 ; }
Return whether a string starts with a term
14,813
public static function explode ( string $ subject , string $ delimiter , int $ limit = null ) : Bag { if ( empty ( $ delimiter ) ) { return new Bag ( ) ; } $ parts = $ limit === null ? explode ( $ delimiter , $ subject ) : explode ( $ delimiter , $ subject , $ limit ) ; return new Bag ( $ parts ? : [ ] ) ; }
Splits a string on the delimiter .
14,814
public function getEquationQty ( ) { $ tbl = $ this -> _resource -> getTableName ( self :: TBL_WRHS_QTY ) ; $ result = 'SUM(`' . $ tbl . '`.`' . Quantity :: A_TOTAL . '`)' ; return $ result ; }
MOBI - 397
14,815
public function modifySelect ( \ Magento \ Framework \ DB \ Select $ select ) { $ tblEntity = 'e' ; $ tblStockItem = $ this -> _resource -> getTableName ( self :: TBL_STOCK_ITEM ) ; $ tblWrhsQty = $ this -> _resource -> getTableName ( self :: TBL_WRHS_QTY ) ; $ fldStockItemProdId = StockItem :: PRODUCT_ID ; $ fldStockI...
Add JOINs to original select .
14,816
public function startCommand ( ) : void { $ daemon = $ this -> getSameOpt ( [ 'd' , 'daemon' ] ) ; $ this -> createServer ( ) -> asDaemon ( $ daemon ) -> start ( ) ; }
start the application server
14,817
public function restartCommand ( ) : void { $ daemon = $ this -> input -> getSameOpt ( [ 'd' , 'daemon' ] ) ; $ this -> createServer ( ) -> asDaemon ( $ daemon ) -> restart ( ) ; }
restart the application server
14,818
public function reloadCommand ( ) : void { $ onlyTask = $ this -> input -> getSameOpt ( [ 'task' ] ) ; $ this -> createServer ( ) -> reload ( $ onlyTask ) ; }
reload the application server workers
14,819
public function template_column_orderby ( $ vars ) { if ( is_admin ( ) && isset ( $ vars [ 'orderby' ] ) && 'snap_template' === $ vars [ 'orderby' ] ) { $ vars = \ array_merge ( $ vars , [ 'orderby' => 'not_exists_clause title' , 'meta_query' => [ 'relation' => 'OR' , 'exists_clause' => [ 'key' => '_wp_page_template' ,...
Define custom orderby rules for custom sortable columns .
14,820
protected function getApi ( ) { if ( ! $ this -> api ) { $ this -> api = new Transport ( $ this -> user , $ this -> password ) ; } return $ this -> api ; }
Retrieve the transport client .
14,821
protected function getAllTxFiles ( $ language ) { $ iterator = new \ DirectoryIterator ( $ this -> txlang . DIRECTORY_SEPARATOR . $ language ) ; $ files = array ( ) ; while ( $ iterator -> valid ( ) ) { if ( ! $ iterator -> isDot ( ) && $ iterator -> isFile ( ) && $ iterator -> getExtension ( ) == 'xlf' && $ this -> is...
Retrieve all XLIFF for a given language .
14,822
private function getUser ( InputInterface $ input , OutputInterface $ output ) { if ( $ user = $ input -> getOption ( 'user' ) ) { return $ user ; } if ( $ user = $ this -> getTransifexConfigValue ( '/user' ) ) { $ this -> writelnVerbose ( $ output , 'Using transifex user specified in config.' ) ; return $ user ; } if ...
Retrieve the user name .
14,823
private function getPassword ( InputInterface $ input , OutputInterface $ output ) { if ( $ pass = $ input -> getOption ( 'pass' ) ) { return $ pass ; } if ( $ pass = $ this -> getTransifexConfigValue ( '/pass' ) ) { $ this -> writelnVerbose ( $ output , 'Using transifex password specified in config.' ) ; return $ pass...
Retrieve the password .
14,824
public static function TypeCodeForXmlType ( $ xmlType ) { if ( is_null ( $ xmlType ) || ! is_scalar ( $ xmlType ) ) { return XmlTypeCode :: UntypedAtomic ; } $ types = SchemaTypes :: getInstance ( ) ; $ atom = $ types -> getAtomicType ( $ xmlType ) ; return isset ( XmlTypeCode :: $ typeToCodeMap [ $ atom ] ) ? XmlTypeC...
Get a type code for an XML type name
14,825
public static function getTypeForCode ( $ typeCode ) { return isset ( XmlTypeCode :: $ codeToTypeMap [ $ typeCode ] ) ? XmlTypeCode :: $ codeToTypeMap [ $ typeCode ] : false ; }
Look up the Xml type associated with a type code
14,826
public function boot ( ) { $ this -> add_action ( $ this -> get_cron_action ( ) , 'handler' ) ; if ( \ wp_get_schedule ( $ this -> get_cron_action ( ) ) !== $ this -> schedule ) { \ wp_clear_scheduled_hook ( $ this -> get_cron_action ( ) ) ; } if ( ! \ wp_next_scheduled ( $ this -> get_cron_action ( ) ) ) { \ wp_schedu...
Boot the AJAX Hookable and register the handler .
14,827
protected function getCacheHash ( $ id ) { if ( is_array ( $ id ) ) { $ id = Util :: filterScalarValues ( $ id ) ; $ id = array_map ( function ( $ child ) { return ( string ) $ child ; } , $ id ) ; sort ( $ id ) ; } else { $ id = ( string ) $ id ; } return md5 ( json_encode ( array ( spl_object_hash ( $ this -> queryBu...
Returns cache key for found result
14,828
protected function extractLabel ( $ object ) { if ( $ this -> property ) { if ( $ this -> property instanceof \ Closure ) { return $ this -> property -> __invoke ( $ object ) ; } else { return $ this -> accessor -> getValue ( $ object , $ this -> property ) ; } } elseif ( method_exists ( $ object , '__toString' ) ) { r...
Extract property that should be used for displaying the entities as text in the HTML element
14,829
public function coreHeartbeat ( $ location ) { add_action ( 'init' , function ( ) use ( $ location ) { if ( 'all' === $ location ) { wp_deregister_script ( 'heartbeat' ) ; } else if ( OL_ZEUS_ISADMIN ) { global $ pagenow ; if ( ( 'admin' === $ location && 'post.php' !== $ pagenow && 'post-new.php' !== $ pagenow ) || ( ...
Remove HeartBeat scripts
14,830
public function coreJqueryMigrate ( ) { if ( OL_ZEUS_ISADMIN ) { return ; } add_action ( 'wp_default_scripts' , function ( $ scripts ) { if ( ! empty ( $ scripts -> registered [ 'jquery' ] ) ) { $ scripts -> registered [ 'jquery' ] -> deps = array_diff ( $ scripts -> registered [ 'jquery' ] -> deps , [ 'jquery-migrate'...
Remove jQuery Migrate default script
14,831
public function coreJsonApi ( ) { if ( ! OL_ZEUS_ISADMIN ) { remove_action ( 'wp_head' , 'rest_output_link_wp_head' , 10 ) ; remove_action ( 'wp_head' , 'wp_oembed_add_discovery_links' , 10 ) ; remove_action ( 'wp_head' , 'wp_oembed_add_discovery_links' ) ; remove_action ( 'wp_head' , 'wp_oembed_add_host_js' ) ; remove...
Remove json api and link from header
14,832
public function Start ( ) { $ this -> definitions_path = rtrim ( $ this -> definitions_path , "/\\" ) ; $ this -> document = new DOMDocument ( ) ; $ this -> document -> load ( $ this -> definitions_path . "/index.xml" ) ; $ this -> ExtractConstants ( $ this -> document ) ; $ this -> ExtractEnumerations ( $ this -> docu...
Initializes the parsing process
14,833
private function ExtractEnumerations ( \ DOMDocument $ document , $ namespace = "" ) { $ xpath = new DOMXPath ( $ document ) ; $ entries = $ xpath -> evaluate ( "//compound[@kind='file'] | //compound[@kind='namespace']" , $ document ) ; for ( $ i = 0 ; $ i < $ entries -> length ; $ i ++ ) { $ kind = $ entries -> item (...
Extract named enumerations .
14,834
private function ExtractVariables ( \ DOMDocument $ document , $ namespace = "" ) { $ xpath = new DOMXPath ( $ document ) ; $ entries = $ xpath -> evaluate ( "//compound[@kind='file'] | //compound[@kind='namespace']" , $ document ) ; for ( $ i = 0 ; $ i < $ entries -> length ; $ i ++ ) { $ kind = $ entries -> item ( $ ...
Extract global variables .
14,835
private function ExtractTypeDefinitions ( \ DOMDocument $ document , $ namespace = "" ) { $ xpath = new DOMXPath ( $ document ) ; $ entries = $ xpath -> evaluate ( "//compound[@kind='file'] | //compound[@kind='namespace']" , $ document ) ; for ( $ i = 0 ; $ i < $ entries -> length ; $ i ++ ) { $ kind = $ entries -> ite...
Extract typedef declared on the source files .
14,836
public function send ( $ data = null ) : ? MailSettings { try { $ settings = $ this -> createSettings ( $ data ) ; $ settings -> hasRequiredSettings ( ) ; $ this -> mailer -> send ( $ this -> createMailable ( $ settings ) ) ; } catch ( \ Exception $ e ) { Log :: error ( $ e ) ; $ env = $ this -> config -> get ( 'app.en...
Create and send mail
14,837
protected function createSettings ( $ data = null ) : MailSettings { if ( method_exists ( $ this , 'getPayload' ) ) { $ data = $ this -> getPayload ( $ data ) ; } if ( $ data instanceof MailSettings ) { return $ data ; } return new $ this -> settings ( $ data ) ; }
Create mail settings
14,838
public function fetchHeadCommitHash ( ) : ? string { if ( ! \ is_dir ( "{$this->projectDir}/.git" ) ) { return null ; } $ git = $ this -> run ( 'command -v git' ) ; return null !== $ git ? $ this -> run ( "{$git} rev-parse HEAD" ) : null ; }
Fetches the commit hash of the current HEAD
14,839
private function run ( string $ command ) : ? string { $ result = \ trim ( \ shell_exec ( $ command ) ?? "" ) ; return "" !== $ result ? $ result : null ; }
Runs the given command
14,840
public static function getValue ( $ enumKey = '' ) { foreach ( self :: all ( ) as $ key => $ value ) { if ( strtolower ( $ key ) == strtolower ( $ enumKey ) ) { return $ value ; } } return null ; }
Return a value from a key
14,841
public static function getKey ( $ enumValue = '' ) { foreach ( self :: all ( ) as $ key => $ value ) { if ( strtolower ( $ value ) == strtolower ( $ enumValue ) ) { return $ key ; } } return null ; }
Return a key from a value
14,842
public function unregister ( ResponderInterface $ responder ) { $ key = array_search ( $ responder , $ this -> queue , true ) ; if ( $ key !== false ) { unset ( $ this -> queue [ $ key ] ) ; } return $ this ; }
Remove ResponderInterface object from the queue
14,843
public function flashMessage ( $ message , $ type = FlashMessage :: TYPE_SUCCESS , $ method = FlashMessage :: METHOD_APPEND ) { $ message = new FlashMessage ( $ message , $ type , $ method ) ; $ this -> register ( $ message ) ; return $ message ; }
Create a FlashMessage and register it to the queue
14,844
public function modal ( $ html , $ type = Modal :: DEFAULT_TYPE ) { $ modal = new Modal ( $ html , $ type ) ; $ this -> register ( $ modal ) ; return $ modal ; }
Create a Modal and register it to the queue
14,845
public function callback ( $ function , $ params = null ) { $ callback = new Callback ( $ function , $ params ) ; $ this -> register ( $ callback ) ; return $ callback ; }
Create a Callback and register it to the queue
14,846
public function changeUrl ( $ url , $ method = ChangeUrl :: PUSH , $ wait = 0 ) { $ changeUrl = new ChangeUrl ( $ url , $ method , $ wait ) ; $ this -> register ( $ changeUrl ) ; return $ changeUrl ; }
Create a ChangeUrl and register it to the queue
14,847
public function send ( $ event ) { if ( Yii :: $ app -> user -> isGuest ) { $ profile = Yii :: $ app -> request -> post ( 'Profile' ) ; $ partnerRequest = Yii :: $ app -> request -> post ( 'PartnerRequest' ) ; $ partnerEmail = [ Yii :: $ app -> request -> post ( 'register-form' ) [ 'email' ] ] ; $ userMailVars = [ '{na...
Sends emails about partner request to manager and partner
14,848
public function get ( string $ route , $ body = [ ] , $ headers = [ ] ) { return $ this -> request ( 'GET' , $ route , $ body , $ headers ) ; }
Http get request
14,849
public function request ( string $ verb , string $ route , $ body = [ ] , $ headers = [ ] ) : Collection { $ request = $ this -> createRequest ( $ verb , $ route , $ body , $ headers ) ; $ request = $ this -> authenticateRequest ( $ request ) ; $ collection = $ this -> dispatchRequest ( $ request ) ; return $ collectio...
Makes a http request
14,850
protected function createRequest ( string $ verb , string $ route , $ body = [ ] , $ headers = [ ] ) { $ url = Router :: getRouteUrl ( $ route ) ; if ( strtoupper ( $ verb ) === 'GET' ) { $ url .= '?' . http_build_query ( $ body ) ; } $ request = new Request ( $ verb , $ url , $ this -> mergeDefaultHeaders ( $ headers ...
Creates and sets the request instance
14,851
protected function authenticateRequest ( Request $ request ) { if ( $ this -> authenticator && $ this -> authenticate ) { return $ this -> authenticator -> authenticate ( $ request ) ; } return $ request ; }
Gets the request authenticator
14,852
protected function dispatchRequest ( Request $ request ) : Collection { try { $ response = $ this -> client -> send ( $ request ) ; $ this -> response = $ response ; return $ this -> parseResponse ( $ response ) ; } catch ( ClientException $ exception ) { $ this -> response = $ exception -> getResponse ( ) ; if ( $ thi...
Dispatches a request and returns a response instance
14,853
protected function parseResponse ( Response $ response ) { if ( $ response -> getStatusCode ( ) > 199 && $ response -> getStatusCode ( ) < 299 ) { if ( $ body = json_decode ( $ response -> getBody ( ) -> getContents ( ) , 1 ) ) { return new Collection ( $ body ) ; } } return new Collection ; }
Prases a response and returns a collection or item
14,854
public function post ( string $ route , $ body = [ ] , $ headers = [ ] ) { return $ this -> request ( 'POST' , $ route , $ body , $ headers ) ; }
Http post request
14,855
public function put ( string $ route , $ body = [ ] , $ headers = [ ] ) { return $ this -> request ( 'PUT' , $ route , $ body , $ headers ) ; }
Http put request
14,856
public function patch ( string $ route , $ body = [ ] , $ headers = [ ] ) { return $ this -> request ( 'PATCH' , $ route , $ body , $ headers ) ; }
Http patch request
14,857
public function delete ( string $ route , $ body = [ ] , $ headers = [ ] ) { return $ this -> request ( 'DELETE' , $ route , $ body , $ headers ) ; }
Http delete request
14,858
private function verifyMigrated ( ) { $ process = new Process ( 'php artisan migrate:status' ) ; $ process -> run ( ) ; if ( strpos ( $ process -> getOutput ( ) , 'No migrations found' ) !== false ) { $ this -> comment ( 'Running migrate command...' ) ; $ this -> call ( 'migrate' ) ; } }
Run the initial migrate command if it has not been run .
14,859
private function seedUserTables ( ) { if ( Status :: count ( ) === 0 ) { $ this -> comment ( 'Seeding user_statuses...' ) ; $ this -> call ( 'db:seed' , [ '--class' => 'UserStatus' ] ) ; } else { $ this -> comment ( 'Table user_statuses is not empty. Skipping seed...' ) ; } if ( Role :: count ( ) === 0 ) { $ this -> c...
Set up the default data for user tables .
14,860
public function getComments ( ) { $ args_comments = [ 'post_id' => $ this -> ID , 'orderby' => 'comment_date_gmt' , 'status' => static :: STATUS_APPROVE , ] ; $ comments = [ ] ; foreach ( get_comments ( $ args_comments , $ this -> ID ) as $ c ) { $ comments [ ] = Comment :: find ( $ c -> comment_ID ) ; } return $ comme...
Return all comments
14,861
public function getDate ( ) { global $ wpdb ; return $ wpdb -> get_var ( $ wpdb -> prepare ( 'SELECT post_date FROM ' . $ wpdb -> prefix . 'posts WHERE ID = %d' , $ this -> ID ) ) ; }
Return the publish date
14,862
public function getFormComments ( ) { ob_start ( ) ; $ placeTextarea = App :: get ( 'i18n' ) -> transu ( 'post.share_comment' ) ; $ params = [ 'comment_notes_after' => '' , 'author' => '<p class="comment-form-author">' . '<label for="author">' . __ ( 'Your Name' ) . '</label> <input id="author" name="author" type="...
Return the form for comments
14,863
public function getDateModified ( ) { global $ wpdb ; return $ wpdb -> get_var ( $ wpdb -> prepare ( 'SELECT post_modified FROM ' . $ wpdb -> prefix . 'posts WHERE ID = %d' , $ this -> ID ) ) ; }
Return the modified date
14,864
public function getThumbnail ( $ size = self :: IMG_SIZE_THUMBNAIL ) { $ getSrc = function ( $ _id ) use ( $ size ) { $ imageObject = wp_get_attachment_image_src ( get_post_thumbnail_id ( $ _id ) , $ size ) ; if ( empty ( $ imageObject ) ) { return false ; } return $ imageObject [ 0 ] ; } ; if ( ( $ imageObject = $ get...
Devuelve el src del thumbnail del post
14,865
public static function getFuncBy ( $ by ) { return function ( $ value = false , $ limit = false , $ offset = false , $ moreQuerySettings = [ ] ) use ( $ by ) { switch ( $ by ) { case Ajax :: ARCHIVE : return static :: getByArchive ( $ value , $ limit , $ offset , $ moreQuerySettings ) ; case Ajax :: AUTHOR : return sta...
Return a clousure
14,866
private static function getStickyPosts ( $ limit = - 1 , $ offset = false , $ moreQuerySettings = [ ] ) { $ sticky_posts = Option :: get ( 'sticky_posts' ) ; if ( ! $ sticky_posts ) { return [ ] ; } if ( ! isset ( $ moreQuerySettings [ 'post_type' ] ) ) { $ moreQuerySettings [ 'post_type' ] = Post :: TYPE_POST ; } $ qu...
Return the fixed posts
14,867
private static function loopQueryPosts ( $ loop ) { $ posts = [ ] ; for ( $ index = 0 ; $ loop -> have_posts ( ) ; $ index ++ ) { $ loop -> the_post ( ) ; $ posts [ ] = Post :: find ( get_the_ID ( ) ) ; } return $ posts ; }
Loop the query and mount the Post objects
14,868
public static function getByArchive ( $ value , $ limit = false , $ offset = false , $ moreQuerySettings = [ ] ) { return self :: getBy ( Ajax :: ARCHIVE , $ value , $ limit , $ offset , $ moreQuerySettings ) ; }
Get posts from an archive
14,869
public static function getByAuthor ( $ autorId , $ limit = false , $ offset = false , $ moreQuerySettings = [ ] ) { return self :: getBy ( Ajax :: AUTHOR , $ autorId , $ limit , $ offset , $ moreQuerySettings ) ; }
Get posts from an author
14,870
public static function getBySearch ( $ searchQuery , $ limit = false , $ offset = false , $ moreQuerySettings = [ ] ) { return self :: getBy ( Ajax :: SEARCH , $ searchQuery , $ limit , $ offset , $ moreQuerySettings ) ; }
Get posts from query search
14,871
public static function getByCategory ( $ catId , $ limit = false , $ offset = false , $ moreQuerySettings = [ ] ) { return self :: getBy ( Ajax :: CATEGORY , $ catId , $ limit , $ offset , $ moreQuerySettings ) ; }
Get posts from a category
14,872
public function store ( ) { if ( ! $ this -> _runtime_queries || $ this -> already_saved ) { return ; } $ this -> already_saved = true ; $ path = defined ( 'PATH' ) ? PATH : ( defined ( 'PATH_INTERNAL' ) ? PATH_INTERNAL : '' ) ; $ objects = [ ] ; foreach ( $ this -> _runtime_queries as $ query ) { $ query_obj = new DbQ...
Save all queries to DB
14,873
public static function getUrl ( $ lng , $ object = NULL ) { if ( ! self :: exists ( $ lng ) ) { return false ; } $ res = '/' . $ lng . '/' ; $ router = Router :: getInstance ( ) ; $ current_page = $ router -> getPageData ( ) ; $ path = $ router -> getPath ( ) ; $ page_url_by_label = Structure :: getPathByLabel ( $ curr...
Gets url of same page for selected language
14,874
public static function exists ( $ short ) { if ( self :: $ __domain_restricted_languages && ! in_array ( $ short , self :: $ __domain_restricted_languages ) ) { return false ; } $ cache_key = 'language_exists_' . $ short ; $ res = NULL ; if ( Settings :: isCacheEnabled ( ) ) { $ res = Cacher :: getInstance ( ) -> getDe...
Check if language exists
14,875
public function getRepositories ( array $ domains = [ ] , array $ languages = [ ] ) : array { $ repositories = array_filter ( $ this -> repositories , function ( Repository $ repository ) use ( $ domains ) { return empty ( $ domains ) || in_array ( $ repository -> getDomain ( ) , $ domains ) ; } ) ; return array_filter...
Get Repositories .
14,876
public static function generateKeypair ( ) : Keypair { try { $ keypair = \ sodium_crypto_box_keypair ( ) ; return new Keypair ( \ sodium_crypto_box_secretkey ( $ keypair ) , \ sodium_crypto_box_publickey ( $ keypair ) ) ; } catch ( SodiumException $ e ) { throw new Exception ( $ e -> getMessage ( ) ) ; } }
Generates a crypto keypair
14,877
public static function generateSigningKeypair ( ) : Keypair { try { $ keypair = \ sodium_crypto_sign_keypair ( ) ; return new Keypair ( \ sodium_crypto_sign_secretkey ( $ keypair ) , \ sodium_crypto_sign_publickey ( $ keypair ) ) ; } catch ( SodiumException $ e ) { throw new Exception ( $ e -> getMessage ( ) ) ; } }
Generates a signing keypair
14,878
protected function authenticate ( $ key , $ secret ) { $ token = $ this -> cache -> get ( 'Twitter_Application_Bearer_Token' ) ; if ( $ token === FALSE ) { $ bearerTokenCredentials = base64_encode ( urlencode ( $ key ) . ':' . urlencode ( $ secret ) ) ; $ uri = new Uri ( 'https://api.twitter.com/oauth2/token' ) ; $ htt...
Does the actual authentication with Twitter . Should probably move to a oauth package to allow generic application only authentication with oauth .
14,879
public function setItems ( $ items ) { foreach ( $ this -> items as $ item ) { $ item -> setOrder ( null ) ; } foreach ( $ items as $ item ) { $ item -> setOrder ( $ this ) ; } $ this -> items = $ items ; return $ this ; }
Sets the items .
14,880
public function start ( int $ timeout_ms = 3000 ) : void { $ port = $ this -> config -> getPort ( ) ; $ this -> logger -> notice ( "Starting standalone server on port $port." ) ; if ( $ this -> isStarted ( ) ) { $ this -> logger -> notice ( 'Standalone server already running, skipping start.' ) ; return ; } if ( ! $ th...
Start the standalone server .
14,881
public function stop ( bool $ throwException = false , bool $ clearPidFileOnException = false ) : void { $ this -> logger -> notice ( 'Stopping server' ) ; try { $ pid = $ this -> getPid ( ) ; $ running = $ this -> isProcessRunning ( true ) ; if ( ! $ running ) { if ( $ throwException ) { $ msg = "Cannot stop: pid exis...
Stop the standalone server .
14,882
public function isStarted ( bool $ test_is_running = true ) : bool { if ( ! $ this -> started && $ test_is_running ) { $ this -> started = $ this -> isProcessRunning ( ) ; } return $ this -> started ; }
Tells whether the standalone server is started .
14,883
public function getCommand ( ) : string { $ port = $ this -> config -> getPort ( ) ; $ java_bin = $ this -> config -> getJavaBin ( ) ; $ jars = [ ] ; $ classpaths = $ this -> config -> getClasspaths ( ) ; foreach ( $ classpaths as $ classpath ) { if ( preg_match ( '/\*\.jar$/' , $ classpath ) ) { $ directory = preg_rep...
Return command used to start the standalone server .
14,884
public function getPid ( ) : int { $ pid_file = $ this -> config -> getPidFile ( ) ; if ( ! file_exists ( $ pid_file ) ) { $ msg = "Pid file cannot be found '$pid_file'" ; $ this -> logger -> info ( "Get PID failed: $msg" ) ; throw new Exception \ PidNotFoundException ( $ msg ) ; } $ pid = trim ( file_get_contents ( $ ...
Get standalone server pid number as it was stored during last start .
14,885
public function getOutput ( ) : string { $ log_file = $ this -> config -> getLogFile ( ) ; if ( ! file_exists ( $ log_file ) ) { $ msg = "Server output log file does not exists '$log_file'" ; $ this -> logger -> error ( "Get server output failed: $msg" ) ; throw new Exception \ RuntimeException ( $ msg ) ; } elseif ( !...
Return the content of the output_file .
14,886
public function isProcessRunning ( bool $ throwsException = false ) : bool { $ running = false ; try { $ pid = $ this -> getPid ( ) ; $ isRunning = $ this -> process -> isRunning ( $ pid ) ; if ( $ isRunning ) { $ this -> logger -> debug ( "Pid '${pid}' running." ) ; $ running = true ; } else { $ this -> logger -> debu...
Test whether the standalone server process is effectively running .
14,887
public static function factory ( $ config = array ( ) ) { $ default = array ( ) ; $ required = array ( 'base_url' ) ; $ config = Inspector :: prepareConfig ( $ config , $ default , $ required ) ; $ client = new self ( $ config -> get ( 'base_url' ) , $ config -> get ( 'token' ) ) ; $ client -> setConfig ( $ config ) ; ...
Factory method to create a new IdentityClient
14,888
protected function recordActivity ( $ event ) { $ this -> activity ( ) -> create ( [ 'user_id' => auth ( ) -> id ( ) , 'type' => $ this -> getActivityType ( $ event ) ] ) ; }
Record new activity for the model .
14,889
public function Start ( ) { if ( ! file_exists ( $ this -> definitions_path ) ) { throw new \ Exception ( t ( "Trying to import symbols from a non existent directory." ) ) ; } $ this -> SendMessage ( sprintf ( t ( "Starting import of definitions stored in %s format." ) , $ this -> import_type ) ) ; if ( $ this -> impor...
Begin importing definitions to the symbols object specified on constructor .
14,890
private function LoadFromPHP ( $ path ) { $ this -> definitions_path = rtrim ( $ path , "/\\" ) . "/" ; $ this -> import_type = Type :: PHP ; $ symbols = & $ this -> symbols ; if ( file_exists ( $ this -> definitions_path . "constants.php" ) ) { $ this -> SendMessage ( t ( "Loading constants.php" ) ) ; include ( $ this...
Load all kind of symbols from php files previously created by \ Peg \ Lib \ Definitions \ Exporter .
14,891
private function LoadFromJSON ( $ path ) { $ this -> definitions_path = rtrim ( $ path , "/\\" ) . "/" ; $ this -> import_type = Type :: JSON ; if ( file_exists ( $ this -> definitions_path . "constants.json" ) ) { $ this -> SendMessage ( t ( "Loading constants.json" ) ) ; $ this -> LoadConstantsFromJson ( ) ; } if ( f...
Load all kind of symbols from json files previously created by \ Peg \ Lib \ Definitions \ Exporter .
14,892
private function LoadConstantsFromJson ( ) { $ constants_def = Json :: Decode ( file_get_contents ( $ this -> definitions_path . "constants.json" ) ) ; foreach ( $ constants_def as $ header => $ namespaces ) { $ this -> symbols -> AddHeader ( $ header ) ; foreach ( $ namespaces as $ namespace => $ constants ) { foreach...
Load all constant symbols from constants . json
14,893
private function LoadEnumerationsFromJson ( ) { $ enumerations_def = Json :: Decode ( file_get_contents ( $ this -> definitions_path . "enumerations.json" ) ) ; foreach ( $ enumerations_def as $ header => $ namespaces ) { $ this -> symbols -> AddHeader ( $ header ) ; foreach ( $ namespaces as $ namespace => $ enumerati...
Load all enumeration symbols from enumerations . json
14,894
private function LoadTypeDefFromJson ( ) { $ typedef_def = Json :: Decode ( file_get_contents ( $ this -> definitions_path . "type_definitions.json" ) ) ; foreach ( $ typedef_def as $ header => $ namespaces ) { $ this -> symbols -> AddHeader ( $ header ) ; foreach ( $ namespaces as $ namespace => $ typedefs ) { foreach...
Load all typedef symbols from type_definitions . json
14,895
private function LoadGlobalVariablesFromJson ( ) { $ variables_def = Json :: Decode ( file_get_contents ( $ this -> definitions_path . "variables.json" ) ) ; foreach ( $ variables_def as $ header => $ namespaces ) { $ this -> symbols -> AddHeader ( $ header ) ; foreach ( $ namespaces as $ namespace => $ variables ) { f...
Load all global variable symbols from variables . json
14,896
private function LoadFunctionsFromJson ( ) { $ functions_def = Json :: Decode ( file_get_contents ( $ this -> definitions_path . "functions.json" ) ) ; foreach ( $ functions_def as $ header => $ namespaces ) { $ this -> symbols -> AddHeader ( $ header ) ; foreach ( $ namespaces as $ namespace => $ functions ) { foreach...
Load all function symbols from functions . json
14,897
private function load ( ) { if ( ! file_exists ( $ this -> file ) ) { $ this -> createEmptyStore ( ) ; } $ fh = fopen ( $ this -> file , 'r+' ) ; if ( flock ( $ fh , LOCK_SH ) ) { $ rawContent = fread ( $ fh , filesize ( $ this -> file ) ) ; fflush ( $ fh ) ; flock ( $ fh , LOCK_UN ) ; fclose ( $ fh ) ; } else { throw ...
Load contents from store .
14,898
private function save ( ) { $ encodedContent = gzencode ( json_encode ( $ this -> content ) ) ; if ( ! file_exists ( $ this -> file ) ) { touch ( $ this -> file ) ; } $ fh = fopen ( $ this -> file , 'r+' ) ; if ( flock ( $ fh , LOCK_EX ) ) { ftruncate ( $ fh , 0 ) ; fwrite ( $ fh , $ encodedContent ) ; fflush ( $ fh ) ...
Save contents to store .
14,899
public function add ( $ settings ) { if ( is_array ( $ settings ) ) { $ settings = new $ this -> settings ( $ settings ) ; } if ( ! $ settings instanceof ResourceSettings ) { throw new InvalidInstanceException ( 'Settings is not a valid instance of ' . ResourceSettings :: class ) ; } $ settings -> hasRequiredSettings (...
Add and track a new resource