idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
25,700
public function remove ( $ entry ) { foreach ( $ this -> data as $ k => $ v ) { if ( $ v === $ entry ) { $ associative = $ this -> isAssociative ( ) ; unset ( $ this -> data [ $ k ] ) ; if ( $ associative ) { $ this -> data = array_values ( $ this -> data ) ; } return true ; } } return false ; }
Remove an element from the collection .
25,701
public function first ( ) { if ( ! is_array ( $ this -> data ) ) return $ this -> data ; if ( ! count ( $ this -> data ) ) return null ; reset ( $ this -> data ) ; return $ this -> data [ key ( $ this -> data ) ] ; }
Return the very first element .
25,702
public function last ( ) { if ( ! is_array ( $ this -> data ) ) return $ this -> data ; if ( ! count ( $ this -> data ) ) return null ; end ( $ this -> data ) ; return $ this -> data [ key ( $ this -> data ) ] ; }
Return the very last element .
25,703
public static function root ( ) { $ url = request ( 'REQUEST_URI' , '' , 'server' ) ; $ root = request ( 'DOCUMENT_ROOT' , '' , 'server' ) ; $ scheme = request ( 'REQUEST_SCHEME' , '' , 'server' ) ; $ server = request ( 'SERVER_NAME' , '' , 'server' ) ; $ url = substr ( $ url , 1 ) ; $ parts = explode ( '/' , $ url ) ; $ folder = '' ; for ( $ i = 0 ; $ i < count ( $ parts ) ; $ i ++ ) { if ( File :: isDirectory ( $ root . $ folder . $ parts [ $ i ] . '/' ) ) { $ folder .= $ parts [ $ i ] . '/' ; } else { break ; } } return $ scheme . '://' . $ server . '/' . $ folder ; }
Get the route url of the app .
25,704
public static function assertTrue ( $ condition , Throwable $ exception ) : bool { static :: makeAssertion ( true === $ condition , $ exception ) ; return true ; }
Asserts that the given condition is strictly true .
25,705
public static function assertNotTrue ( $ condition , Throwable $ exception ) : bool { static :: makeAssertion ( true !== $ condition , $ exception ) ; return false ; }
Asserts that the given condition is strictly not true .
25,706
public static function assertFalse ( $ condition , Throwable $ exception ) : bool { static :: makeAssertion ( false === $ condition , $ exception ) ; return false ; }
Asserts that the given condition is strictly false .
25,707
public static function assertNotFalse ( $ condition , Throwable $ exception ) : bool { static :: makeAssertion ( false !== $ condition , $ exception ) ; return true ; }
Asserts that the given condition is strictly not false .
25,708
public static function getInstance ( $ label = 'default' ) { $ instance = null ; if ( ! isset ( self :: $ instances [ $ label ] ) ) { $ client = new Client ( ) ; self :: $ instances [ $ label ] = $ client ; } $ instance = self :: $ instances [ $ label ] ; return $ instance ; }
Return an instance of a LibX \ Net \ Rest \ Client with a specific label
25,709
protected function mergeOptions ( ) { $ options = $ this -> getOptions ( ) ; $ sorter = $ options [ 'sorter' ] ; $ sorterNames = $ this -> getSorterParams ( ) ; $ this -> setFilters ( $ this -> listRequest -> getFilters ( $ this -> getName ( ) , $ this -> getFilterSource ( ) ) ) ; $ requestSorter = $ this -> listRequest -> getSorter ( isset ( $ sorterNames [ 'asc' ] ) ? $ sorterNames [ 'asc' ] : 'asc' , isset ( $ sorterNames [ 'desc' ] ) ? $ sorterNames [ 'desc' ] : 'desc' ) ; if ( isset ( $ requestSorter [ 'name' ] ) ) { $ sorter [ 'name' ] = $ requestSorter [ 'name' ] ; } if ( isset ( $ requestSorter [ 'type' ] ) ) { $ sorter [ 'type' ] = $ requestSorter [ 'type' ] ; } $ this -> setSorter ( $ sorter [ 'name' ] , $ sorter [ 'type' ] ) ; return $ this ; }
Merge filters and sorter options from builder and list request .
25,710
public static function camelCaseToSnakeCase ( $ value ) : string { $ value = ToString :: toString ( $ value ) ; $ parts = \ preg_split ( '~([[:upper:]][[:lower:]]+|[^[:upper:]]*[[:lower:]]+)~u' , $ value , - 1 , PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ) ; $ underscored = \ preg_replace ( '~_{2,}~' , '_' , \ implode ( '_' , $ parts ) ) ; return \ strtolower ( $ underscored ) ; }
Converts OnceUponATime to once_upon_a_time
25,711
public static function stripUtf8Bom ( $ string ) : string { $ string = ToString :: toString ( $ string ) ; if ( \ substr_compare ( $ string , "\xEF\xBB\xBF" , 0 , 3 ) !== 0 ) { return $ string ; } $ withoutBom = \ substr ( $ string , 3 ) ; if ( $ withoutBom === false ) { throw new Exceptions \ CanNotRemoveBom ( 'Can not remove BOM from given string ' . $ string ) ; } return $ withoutBom ; }
This method originates from Dropbox
25,712
private function extend_view ( $ text , $ params = array ( ) ) { if ( strpos ( $ text , '@extends(' ) !== false ) { $ pieces = explode ( '@extends(' , $ text ) ; $ pieces = explode ( ')' , $ pieces [ 1 ] ) ; if ( count ( $ pieces ) <= 0 ) return $ text ; $ parent_view = new View ( ViewUtility :: trim ( $ pieces [ 0 ] ) , $ params , false ) ; $ result = $ parent_view -> render ( false ) ; foreach ( ViewUtility :: find_rules ( $ result , '@extends' , ')' ) as $ extend ) { $ result = str_replace ( $ extend , '' , $ result ) ; } $ this -> extended = true ; return $ result ; } return $ text ; }
estendi questo template
25,713
public function attach ( \ SplObserver $ observer ) : void { $ id = spl_object_hash ( $ observer ) ; $ this -> _observers [ $ id ] = $ observer ; }
Attaches an SplObserver to the ExceptionHandler to be notified when an uncaught Exception is thrown .
25,714
public function detach ( \ SplObserver $ observer ) : void { $ id = spl_object_hash ( $ observer ) ; unset ( $ this -> _observers [ $ id ] ) ; }
Detaches the SplObserver from the ExceptionHandler so it will no longer be notified when an uncaught Exception is thrown .
25,715
public function emailOnRegistration ( FilterUserResponseEvent $ event ) { $ template = '@XMSecurity/Mail/user_registered.html.twig' ; $ mailParams = [ 'user' => $ event -> getUser ( ) , ] ; $ this -> mailManager -> getSender ( ) -> setTemplate ( $ template , $ mailParams ) -> send ( $ this -> adminEmail ) ; }
Emails the admin regarding the registration .
25,716
public function isExecutableByLocation ( $ content , \ DateTime $ startDate ) { $ endDateInterval = clone $ startDate ; $ endDateInterval -> modify ( '+' . $ this -> maxDuplicateInterval ) ; if ( $ this -> mustValidate ( $ content , $ startDate ) ) { if ( $ this -> schedulerUtil -> isDueNow ( $ startDate ) || ( $ startDate > new \ DateTime ( ) && $ startDate < $ endDateInterval ) ) { $ connection = $ this -> restClient -> connectByActivity ( $ content -> getOperation ( ) -> getActivity ( ) ) ; try { $ response = $ connection -> getLatestPost ( $ content -> getFacebookLocation ( ) -> getIdentifier ( ) ) ; } catch ( \ Exception $ e ) { throw new ExternalApiException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } if ( isset ( $ response [ 'data' ] ) && isset ( $ response [ 'data' ] [ 0 ] ) && $ response [ 'data' ] [ 0 ] [ 'message' ] == $ content -> getMessage ( ) ) { return array ( 'status' => false , 'message' => 'Same message has already been posted as the latest one on Facebook: ' . '<a href="https://www.facebook.com/' . $ response [ 'data' ] [ 0 ] [ 'id' ] . '">' . 'https://www.facebook.com/' . $ response [ 'data' ] [ 0 ] [ 'id' ] . '</a>. ' . 'Either change the message or leave at least ' . $ this -> maxDuplicateInterval . ' between yours and the other post.' ) ; } } else { $ newActivity = clone $ content -> getOperation ( ) -> getActivity ( ) ; $ newActivity -> setStartDate ( $ startDate ) ; $ closestActivities = array ( ) ; $ closestActivities [ ] = $ this -> em -> getRepository ( 'CampaignChainCoreBundle:Activity' ) -> getClosestScheduledActivity ( $ newActivity , '-' . $ this -> maxDuplicateInterval ) ; $ closestActivities [ ] = $ this -> em -> getRepository ( 'CampaignChainCoreBundle:Activity' ) -> getClosestScheduledActivity ( $ newActivity , '+' . $ this -> maxDuplicateInterval ) ; foreach ( $ closestActivities as $ closestActivity ) { if ( $ closestActivity ) { $ isUniqueContent = $ this -> isUniqueContent ( $ closestActivity , $ content ) ; if ( $ isUniqueContent [ 'status' ] == false ) { return $ isUniqueContent ; } } } } } return array ( 'status' => true , ) ; }
If the Activity is supposed to be executed now we check whether there s an identical post within the past 24 hours .
25,717
public function getSocialId ( ) { $ result = null ; if ( isset ( $ this -> userInfo [ $ this -> socialFieldsMap [ 'socialId' ] ] ) ) { $ result = $ this -> userInfo [ $ this -> socialFieldsMap [ 'socialId' ] ] ; } return $ result ; }
Get user social id or null if it is not set
25,718
public function getEmail ( ) { $ result = null ; if ( isset ( $ this -> userInfo [ $ this -> socialFieldsMap [ 'email' ] ] ) ) { $ result = $ this -> userInfo [ $ this -> socialFieldsMap [ 'email' ] ] ; } return $ result ; }
Get user email or null if it is not set
25,719
public function getSocialPage ( ) { $ result = null ; if ( isset ( $ this -> userInfo [ $ this -> socialFieldsMap [ 'socialPage' ] ] ) ) { $ result = $ this -> userInfo [ $ this -> socialFieldsMap [ 'socialPage' ] ] ; } return $ result ; }
Get user social page url or null if it is not set
25,720
public function getBirthday ( ) { $ result = null ; if ( isset ( $ this -> userInfo [ $ this -> socialFieldsMap [ 'birthday' ] ] ) ) { $ result = date ( 'd.m.Y' , strtotime ( $ this -> userInfo [ $ this -> socialFieldsMap [ 'birthday' ] ] ) ) ; } return $ result ; }
Get user birthday in format dd . mm . YYYY or null if it is not set
25,721
public function getBirthdayObject ( ) { $ birthday = $ this -> getBirthday ( ) ; if ( empty ( $ birthday ) ) { return NULL ; } $ birthday = new DateTime ( $ birthday ) ; return $ birthday ; }
Get user birthday DateTime object
25,722
protected function post ( $ url , $ params , $ parse = true ) { $ curl = curl_init ( ) ; curl_setopt ( $ curl , CURLOPT_URL , $ url ) ; curl_setopt ( $ curl , CURLOPT_POST , 1 ) ; curl_setopt ( $ curl , CURLOPT_POSTFIELDS , $ params ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ curl , CURLOPT_SSL_VERIFYPEER , false ) ; $ result = curl_exec ( $ curl ) ; curl_close ( $ curl ) ; if ( $ parse ) { $ result = json_decode ( $ result , true ) ; } return $ result ; }
Make post request and return result
25,723
protected function get ( $ url , $ params , $ parse = true ) { $ curl = curl_init ( ) ; curl_setopt ( $ curl , CURLOPT_URL , $ url . '?' . urldecode ( http_build_query ( $ params ) ) ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ curl , CURLOPT_SSL_VERIFYPEER , false ) ; $ result = curl_exec ( $ curl ) ; curl_close ( $ curl ) ; if ( $ parse ) { $ result = json_decode ( $ result , true ) ; } return $ result ; }
Make get request and return result
25,724
protected function mapRequestDataToElementCollection ( $ data , ElementCollection $ children ) { $ children -> forAll ( function ( ElementInterface $ element ) use ( $ data ) { $ propertyPath = $ this -> getPropertyPathAsIndex ( $ element ) ; if ( array_key_exists ( $ element -> getName ( ) , $ data ) ) { $ values = $ this -> propertyAccessor -> getValue ( $ data , $ propertyPath ) ; $ this -> mapRequestDataToElement ( $ values , $ element ) ; } } ) ; }
Recursively maps data to children
25,725
public function getUrl ( $ email , $ size = null , $ rating = null , $ default = null , $ secure = null ) { $ hash = md5 ( strtolower ( trim ( $ email ) ) ) ; return $ this -> getUrlForHash ( $ hash , $ size , $ rating , $ default , $ secure ) ; }
Returns a url for a gravatar .
25,726
public function getUrlForHash ( $ hash , $ size = null , $ rating = null , $ default = null , $ secure = null ) { $ map = array ( 's' => $ size ? : $ this -> defaults [ 'size' ] , 'r' => $ rating ? : $ this -> defaults [ 'rating' ] , 'd' => $ default ? : $ this -> defaults [ 'default' ] , ) ; if ( null === $ secure ) { $ secure = $ this -> defaults [ 'secure' ] ; } return ( $ secure ? 'https://secure' : 'http://www' ) . '.gravatar.com/avatar/' . $ hash . '?' . http_build_query ( array_filter ( $ map ) ) ; }
Returns a url for a gravatar for the given hash .
25,727
static function add_path ( $ prefix ) { spl_autoload_register ( function ( $ cn ) use ( $ prefix ) { $ className = ltrim ( $ cn , '\\' ) ; $ fileName = '' ; if ( $ lastNsPos = strrpos ( $ className , '\\' ) ) { $ namespace = substr ( $ className , 0 , $ lastNsPos ) ; $ className = substr ( $ className , $ lastNsPos + 1 ) ; $ fileName = str_replace ( '\\' , DIRECTORY_SEPARATOR , $ namespace ) . DIRECTORY_SEPARATOR ; } $ fileName .= str_replace ( '_' , DIRECTORY_SEPARATOR , $ className ) . '.php' ; $ fileName = $ prefix . DIRECTORY_SEPARATOR . $ fileName ; if ( self :: $ debug ) echo "<div>AUTOLOAD : Considering ($fileName)</div>" ; self :: $ consider_count ++ ; if ( self :: $ consider_count > 500 ) die ( "Consider Count Exceeded" ) ; if ( file_exists ( $ fileName ) ) { if ( self :: $ debug ) echo "<div>AUTOLOAD: Returning $fileName </div>" ; require $ fileName ; return ; } } ) ; }
Adds path to the autoload register
25,728
public function dump ( $ value ) { $ context = $ this -> contextFactory -> createDumpContext ( ) ; return $ this -> dumper -> dump ( $ value , $ context ) ; }
Dump value to a respresentation suitable for json_encode .
25,729
public function update ( GroupInterface $ group ) { $ this -> em -> persist ( $ group ) ; $ this -> em -> flush ( ) ; return true ; }
update the given group
25,730
public function remove ( GroupInterface $ group ) { $ this -> em -> remove ( $ group ) ; $ this -> em -> flush ( ) ; return true ; }
remove the given group
25,731
protected function set ( $ name , $ value ) { if ( $ this -> modified === null && $ this -> uid !== null ) { $ this -> load ( ) ; } $ value = $ this -> validate ( $ name , $ value ) ; if ( $ this -> properties [ $ name ] [ 'value' ] !== $ value ) { $ this -> properties [ $ name ] [ 'value' ] = $ value ; $ this -> modified = true ; } return $ this ; }
Validate and set property value
25,732
protected function get ( $ name ) { if ( $ this -> modified === null ) { $ this -> load ( ) ; } if ( false === array_key_exists ( $ name , $ this -> properties ) ) { throw new Exception ( 'Unknown property "' . $ name . '"' ) ; } return $ this -> resolve ( $ this -> properties [ $ name ] , $ name ) ; }
Get value of given property
25,733
protected function load ( ) { if ( $ this -> uid === null ) { throw new Exception ( 'Entity "' . CamelCase :: to ( $ this -> table ) . '" not initialized' ) ; } $ statement = $ this -> adapter -> getDriver ( ) -> query ( sprintf ( "SELECT t0.* FROM `{$this->table}` AS t0 WHERE t0.`%s` = %s" , $ this -> primary , $ this -> adapter -> getDriver ( ) -> quote ( $ this -> uid , $ this -> properties [ $ this -> primary ] [ 'type' ] ) ) ) ; $ row = $ statement -> fetchAssoc ( ) ; if ( false === is_array ( $ row ) ) { throw new Exception ( 'Entity not found "' . CamelCase :: to ( $ this -> table ) . ' #' . $ this -> uid . '"' ) ; } return $ this -> fromArray ( $ row ) ; }
Load entity by primary key
25,734
protected function parameters ( ) { $ index = 0 ; $ parameters = [ 'p' => [ ] , 'c' => [ ] ] ; foreach ( $ this -> properties as $ name => $ property ) { if ( $ name !== $ this -> primary && false === isset ( $ property [ 'column' ] ) ) { $ index ++ ; $ parameters [ 'p' ] [ $ index ] = $ name . ' = ?' ; $ parameters [ 'c' ] [ $ index ] = $ name ; } } return $ parameters ; }
Create prepared statement parameters
25,735
public function actionIndex ( ) { $ searchModel = new TermTypeSearch ( ) ; $ dataProvider = $ searchModel -> search ( request ( ) -> queryParams ) ; return $ this -> render ( 'index' , [ 'searchModel' => $ searchModel , 'dataProvider' => $ dataProvider , ] ) ; }
Lists all TermType models .
25,736
protected function findModel ( $ id ) { if ( ( $ model = TermType :: findOne ( $ id ) ) !== null ) { return $ model ; } else { throw new NotFoundHttpException ( t ( 'app' , 'The requested page does not exist.' ) ) ; } }
Finds the TermType model based on its primary key value . If the model is not found a 404 HTTP exception will be thrown .
25,737
public function getDbConnection ( ) { if ( is_string ( $ this -> db ) ) { $ this -> db = Yii :: $ app -> get ( $ this -> db ) ; } if ( ! $ this -> db instanceof Connection ) { throw new Exception ( "The 'db' option must refer to the application component ID of a DB connection." ) ; } return $ this -> db ; }
Returns the database connection used to load fixtures .
25,738
public function checkIntegrity ( $ check ) { $ db = $ this -> getDbConnection ( ) ; foreach ( $ this -> schemas as $ schema ) { $ db -> createCommand ( ) -> checkIntegrity ( $ check , $ schema ) -> execute ( ) ; } }
Enables or disables database integrity check . This method may be used to temporarily turn off foreign constraints check .
25,739
public function getRows ( $ name ) { if ( isset ( $ this -> _rows [ $ name ] ) ) return $ this -> _rows [ $ name ] ; else return false ; }
Returns the fixture data rows . The rows will have updated primary key values if the primary key is auto - incremental .
25,740
public function getRecord ( $ name , $ alias ) { if ( isset ( $ this -> _records [ $ name ] [ $ alias ] ) ) { if ( is_string ( $ this -> _records [ $ name ] [ $ alias ] ) ) { $ row = $ this -> _rows [ $ name ] [ $ alias ] ; $ model = ActiveRecord :: model ( $ this -> _records [ $ name ] [ $ alias ] ) ; $ key = $ model -> getRawTableNameSchema ( ) -> primaryKey ; if ( is_string ( $ key ) ) $ pk = $ row [ $ key ] ; else { foreach ( $ key as $ k ) $ pk [ $ k ] = $ row [ $ k ] ; } $ this -> _records [ $ name ] [ $ alias ] = $ model -> find ( $ pk ) ; } return $ this -> _records [ $ name ] [ $ alias ] ; } else return false ; }
Returns the specified ActiveRecord instance in the fixture data .
25,741
public function init ( ) { $ reflection = new ReflectionClass ( $ this -> model ) ; $ this -> properties = $ reflection -> getProperties ( ReflectionProperty :: IS_PROTECTED ) ; return parent :: init ( ) ; }
Widget init function
25,742
public function run ( ) { $ form = $ this -> beginWidget ( 'cii.widgets.CiiActiveForm' , array ( 'id' => get_class ( $ this -> model ) , 'enableAjaxValidation' => true , 'action' => $ this -> action , 'htmlOptions' => array ( 'class' => 'pure-form pure-form-aligned' ) ) ) ; $ this -> renderMain ( $ form ) ; $ this -> endWidget ( ) ; }
The following is run when the widget is called
25,743
private function renderMain ( $ form ) { echo CHtml :: openTag ( 'div' , array ( 'id' => 'main' , 'class' => 'nano' ) ) ; echo CHtml :: openTag ( 'div' , array ( 'class' => 'nano-content' ) ) ; echo CHtml :: openTag ( 'fieldset' ) ; if ( $ this -> model -> form !== NULL ) $ this -> controller -> renderPartial ( $ this -> model -> form , array ( 'model' => $ this -> model , 'properties' => $ this -> properties , 'form' => $ form ) ) ; else if ( count ( $ this -> properties ) == 0 ) { echo CHtml :: tag ( 'legend' , array ( ) , Yii :: t ( 'Dashboard.main' , 'Change Theme Settings' ) ) ; echo CHtml :: tag ( 'div' , array ( 'class' => 'alert alert-info' ) , Yii :: t ( 'Dashboard.main' , 'There are no settings for this section.' ) ) ; } else { $ groups = $ this -> model -> groups ( ) ; if ( ! empty ( $ groups ) ) { foreach ( $ groups as $ name => $ attributes ) { echo CHtml :: tag ( 'legend' , array ( ) , $ name ) ; echo CHtml :: tag ( 'div' , array ( 'class' => 'clearfix' ) , NULL ) ; foreach ( $ attributes as $ property ) { $ p = new StdClass ( ) ; $ p -> name = $ property ; $ this -> renderProperties ( $ form , $ p ) ; } } } else { echo CHtml :: tag ( 'legend' , array ( ) , CiiInflector :: titleize ( get_class ( $ this -> model ) ) ) ; foreach ( $ this -> properties as $ property ) { $ this -> renderProperties ( $ form , $ property ) ; } } } echo CHtml :: closeTag ( 'div' ) ; echo CHtml :: closeTag ( 'div' ) ; echo CHtml :: closeTag ( 'div' ) ; }
Renders the main body content
25,744
private function renderProperties ( & $ form , $ property ) { $ htmlOptions = array ( 'class' => 'pure-input-2-3' ) ; $ validators = $ this -> model -> getValidators ( $ property -> name ) ; $ stringValidators = $ this -> model -> getStringValidator ( $ property -> name , $ validators ) ; if ( in_array ( 'required' , $ stringValidators ) ) $ htmlOptions [ 'required' ] = true ; echo CHtml :: openTag ( 'div' , array ( 'class' => 'pure-control-group' ) ) ; if ( in_array ( 'boolean' , $ stringValidators ) ) $ form -> toggleButtonRow ( $ this -> model , $ property -> name , $ htmlOptions , $ validators ) ; else if ( in_array ( 'number' , $ stringValidators ) && isset ( $ validators [ 0 ] -> max ) && isset ( $ validators [ 0 ] -> min ) ) $ form -> rangeFieldRow ( $ this -> model , $ property -> name , $ htmlOptions , $ validators ) ; else if ( in_array ( 'number' , $ stringValidators ) && ( isset ( $ validators [ 0 ] -> max ) || isset ( $ validators [ 0 ] -> min ) ) ) $ form -> numberFieldRow ( $ this -> model , $ property -> name , $ htmlOptions , $ validators ) ; else if ( in_array ( 'password' , $ stringValidators ) ) echo $ form -> passwordFieldRow ( $ this -> model , $ property -> name , $ htmlOptions , $ validators ) ; else echo $ form -> textFieldRow ( $ this -> model , $ property -> name , $ htmlOptions , $ validators ) ; echo CHtml :: closeTag ( 'div' ) ; }
Renders form properties utilizing the appropriate
25,745
public function importJournalUsers ( $ newJournalId , $ oldJournalId , $ userImporter ) { $ this -> em -> clear ( ) ; $ journal = $ this -> em -> getRepository ( 'VipaJournalBundle:Journal' ) -> find ( $ newJournalId ) ; $ roleMap = [ '1' => "ROLE_ADMIN" , '2' => "ROLE_USER" , '10' => "ROLE_JOURNAL_MANAGER" , '100' => "ROLE_EDITOR" , '200' => 'ROLE_SECTION_EDITOR' , '300' => 'ROLE_LAYOUT_EDITOR' , '1000' => "ROLE_REVIEWER" , '2000' => 'ROLE_COPYEDITOR' , '3000' => "ROLE_PROOFREADER" , '10000' => "ROLE_AUTHOR" , '100000' => 'ROLE_READER' , '200000' => "ROLE_SUBSCRIPTION_MANAGER" , ] ; foreach ( $ roleMap as $ id => $ name ) { $ role = $ this -> em -> getRepository ( 'VipaUserBundle:Role' ) -> findOneBy ( [ 'role' => $ name ] ) ; if ( ! $ role ) { $ role = new Role ( ) ; $ role -> setName ( $ name ) ; $ role -> setRole ( $ name ) ; } $ roleMap [ $ id ] = $ role ; } $ roleStatement = $ this -> dbalConnection -> prepare ( "SELECT roles.journal_id, roles.user_id, roles.role_id, users.email FROM " . "roles JOIN users ON roles.user_id = users.user_id WHERE roles.journal_id" . "= :id " . ImportHelper :: spamUsersFilterSql ( ) ) ; $ roleStatement -> bindValue ( 'id' , $ oldJournalId ) ; $ roleStatement -> execute ( ) ; $ roles = $ roleStatement -> fetchAll ( ) ; $ cache = array ( ) ; foreach ( $ roles as $ role ) { $ email = $ role [ 'email' ] ; if ( empty ( $ cache [ $ email ] [ 'user' ] ) ) { $ cache [ $ email ] [ 'user' ] = $ this -> em -> getRepository ( 'VipaUserBundle:User' ) -> findOneBy ( [ 'email' => $ email ] ) ; } if ( empty ( $ cache [ $ email ] [ 'user' ] ) ) { $ cache [ $ email ] [ 'user' ] = $ userImporter -> importUser ( $ role [ 'user_id' ] , false ) ; } $ journalUser = $ this -> getJournalUser ( $ cache , $ email , $ journal ) ; $ journalUser -> addRole ( $ roleMap [ dechex ( $ role [ 'role_id' ] ) ] ) ; } $ this -> consoleOutput -> writeln ( "Writing data..." ) ; $ this -> em -> flush ( ) ; $ this -> consoleOutput -> writeln ( "Imported users." ) ; }
Imports users of the given journal
25,746
private function getJournalUser ( & $ cache , $ email , $ journal ) { if ( ! empty ( $ cache [ $ email ] [ 'journal_user' ] ) ) { return $ cache [ $ email ] [ 'journal_user' ] ; } $ journalUser = $ this -> em -> getRepository ( 'VipaJournalBundle:JournalUser' ) -> findOneBy ( [ 'journal' => $ journal , 'user' => $ cache [ $ email ] [ 'user' ] ] ) ; if ( $ journalUser === null ) { $ journalUser = new JournalUser ( ) ; $ journalUser -> setUser ( $ cache [ $ email ] [ 'user' ] ) ; $ journalUser -> setJournal ( $ journal ) ; $ this -> em -> persist ( $ journalUser ) ; } $ cache [ $ email ] [ 'journal_user' ] = $ journalUser ; return $ cache [ $ email ] [ 'journal_user' ] ; }
Fetches the journal user
25,747
public function addEvent ( $ start , $ end , $ summary = '' , $ description = '' , $ url = '' , $ uid = '' ) { if ( empty ( $ uid ) ) { $ uid = md5 ( uniqid ( mt_rand ( ) , true ) ) . '@EasyPeasyICS' ; } $ event = array ( 'start' => gmdate ( 'Ymd' , $ start ) . 'T' . gmdate ( 'His' , $ start ) . 'Z' , 'end' => gmdate ( 'Ymd' , $ end ) . 'T' . gmdate ( 'His' , $ end ) . 'Z' , 'summary' => $ summary , 'description' => $ description , 'url' => $ url , 'uid' => $ uid ) ; $ this -> events [ ] = $ event ; return $ event ; }
Add an event to this calendar .
25,748
public function render ( $ output = true ) { $ ics = 'BEGIN:VCALENDARMETHOD:PUBLISHVERSION:2.0X-WR-CALNAME:' . $ this -> calendarName . 'PRODID:-//hacksw/handcal//NONSGML v1.0//EN' ; foreach ( $ this -> events as $ event ) { $ ics .= 'BEGIN:VEVENTUID:' . $ event [ 'uid' ] . 'DTSTAMP:' . gmdate ( 'Ymd' ) . 'T' . gmdate ( 'His' ) . 'ZDTSTART:' . $ event [ 'start' ] . 'DTEND:' . $ event [ 'end' ] . 'SUMMARY:' . str_replace ( "\n" , "\\n" , $ event [ 'summary' ] ) . 'DESCRIPTION:' . str_replace ( "\n" , "\\n" , $ event [ 'description' ] ) . 'URL;VALUE=URI:' . $ event [ 'url' ] . 'END:VEVENT' ; } $ ics .= 'END:VCALENDAR' ; if ( $ output ) { $ filename = $ this -> calendarName ; if ( strpos ( $ filename , ' ' ) !== false ) { $ filename = '"' . $ filename . '"' ; } header ( 'Content-type: text/calendar; charset=utf-8' ) ; header ( 'Content-Disposition: inline; filename=' . $ filename . '.ics' ) ; echo $ ics ; } return $ ics ; }
Render and optionally output a vcal string .
25,749
public function compile ( string $ path , array $ data = [ ] ) { $ path = $ this -> find ( $ path ) ; $ engine = $ this -> factory -> getEngineFromPath ( $ path ) ; return $ view = new View ( $ this -> factory , $ engine , $ path , $ path , $ data ) ; }
Compile a specific Blade file
25,750
public function find ( string $ path ) { if ( ! file_exists ( $ path ) ) { $ path = $ this -> viewFinder -> find ( $ path ) ; } return $ path ; }
Searches the viewFinder for the path provided
25,751
protected function checkValue ( ) : void { if ( ( ! is_string ( $ this -> value ) && ! is_numeric ( $ this -> value ) ) || strtotime ( $ this -> value ) === false ) { throw new InvalidArgumentException ( 'DateParser: Value must be a valid date' ) ; } }
Check if value is a valid date .
25,752
public function render ( array $ attrs , $ urlType ) { return HtmlRenderer :: factory ( $ this -> renderer , $ this -> dataObject , $ urlType , $ attrs ) ; }
Render the data object into valid HTML markup
25,753
private function upgradeTblQuote ( $ setup ) { $ conn = $ setup -> getConnection ( ) ; $ table = $ setup -> getTable ( EPartQuote :: ENTITY_NAME ) ; $ conn -> addColumn ( $ table , EPartQuote :: A_BASE_CURRENCY , [ 'type' => \ Magento \ Framework \ DB \ Ddl \ Table :: TYPE_TEXT , 'length' => 3 , 'nullable' => false , 'after' => EPartQuote :: A_BASE_PARTIAL_AMOUNT , 'comment' => 'Currency code for base amount (stock/warehouse currency).' ] ) ; $ conn -> addColumn ( $ table , EPartQuote :: A_CURRENCY , [ 'type' => \ Magento \ Framework \ DB \ Ddl \ Table :: TYPE_TEXT , 'length' => 3 , 'nullable' => false , 'after' => EPartQuote :: A_PARTIAL_AMOUNT , 'comment' => 'Currency code for amount (payment??? currency).' ] ) ; }
Upgrade table prxgt_wallet_partial_quote . Add currencies fields .
25,754
private function upgradeTblSale ( $ setup ) { $ conn = $ setup -> getConnection ( ) ; $ table = $ setup -> getTable ( EPartSale :: ENTITY_NAME ) ; $ conn -> addColumn ( $ table , EPartSale :: A_TRANS_REF , [ 'type' => \ Magento \ Framework \ DB \ Ddl \ Table :: TYPE_INTEGER , 'length' => null , 'unsigned' => true , 'nullable' => false , 'after' => EPartSale :: A_SALE_ORDER_REF , 'comment' => 'Transaction Reference.' ] ) ; $ conn -> addColumn ( $ table , EPartSale :: A_BASE_CURRENCY , [ 'type' => \ Magento \ Framework \ DB \ Ddl \ Table :: TYPE_TEXT , 'length' => 3 , 'nullable' => false , 'after' => EPartSale :: A_BASE_PARTIAL_AMOUNT , 'comment' => 'Currency code for base amount (stock/warehouse currency).' ] ) ; $ conn -> addColumn ( $ table , EPartSale :: A_CURRENCY , [ 'type' => \ Magento \ Framework \ DB \ Ddl \ Table :: TYPE_TEXT , 'length' => 3 , 'nullable' => false , 'after' => EPartSale :: A_PARTIAL_AMOUNT , 'comment' => 'Currency code for amount (payment??? currency).' ] ) ; $ tbl = $ setup -> getTable ( EPartSale :: ENTITY_NAME ) ; $ tblRef = $ setup -> getTable ( EAccTran :: ENTITY_NAME ) ; $ fkName = $ setup -> getFkName ( $ tbl , $ tblRef , EPartSale :: A_TRANS_REF , EAccTran :: A_ID ) ; $ conn -> addForeignKey ( $ fkName , $ tbl , EPartSale :: A_TRANS_REF , $ tblRef , EAccTran :: A_ID ) ; }
Upgrade table prxgt_wallet_partial_sale . Add currencies fields and transaction reference .
25,755
protected function cleanUrl ( $ alias ) { if ( $ this -> isOldRealUrlVersion ( ) ) { $ realUrl = GeneralUtility :: makeInstance ( 'tx_realurl_advanced' ) ; $ configuration = $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'EXTCONF' ] [ 'realurl' ] [ '_DEFAULT' ] [ 'pagePath' ] ; if ( \ is_array ( $ configuration ) ) { ObjectAccess :: setProperty ( $ realUrl , 'conf' , $ configuration , true ) ; } $ processedTitle = $ realUrl -> encodeTitle ( $ alias ) ; } else { $ configuration = GeneralUtility :: makeInstance ( ConfigurationReader :: class , ConfigurationReader :: MODE_ENCODE ) ; $ utility = GeneralUtility :: makeInstance ( Utility :: class , $ configuration ) ; $ processedTitle = $ utility -> convertToSafeString ( $ alias ) ; } return $ processedTitle ; }
Generate the realurl part .
25,756
public static function init ( ) { $ app = Application :: fromCwd ( ) ; $ app -> initializeProxies ( ) ; $ app -> boot ( ) ; static :: $ appPath = \ App :: appPath ( ) ; static :: $ vendorPath = \ App :: vendorPath ( ) ; if ( defined ( 'COMPILING' ) ) { static :: $ appPath = BUILD_PATH . '/app' ; static :: $ vendorPath = BUILD_PATH . '/vendor' ; } }
Initialise the application
25,757
public static function postInstall ( Event $ event ) { static :: init ( ) ; $ event -> getIO ( ) -> write ( '<info>Writing resources.lock file</info>' ) ; $ installed = json_decode ( file_get_contents ( static :: $ vendorPath . '/composer/installed.json' ) ) ; $ data = [ ] ; $ finder = ( new Finder ) -> directories ( ) -> ignoreVCS ( true ) -> in ( static :: $ resourcesPath . '/packages' ) ; foreach ( $ installed as $ package ) { if ( ! property_exists ( $ package , 'extra' ) ) continue ; $ extra = $ package -> extra ; if ( ! property_exists ( $ extra , 'resources' ) ) continue ; $ resources = $ extra -> resources ; foreach ( $ resources as $ resource => $ namespaces ) { foreach ( $ namespaces as $ namespace => $ path ) { $ finder -> exclude ( $ namespace ) ; $ data [ $ resource ] [ $ namespace ] = $ path ; } } } foreach ( iterator_to_array ( $ finder ) as $ file ) { \ Filesystem :: deleteDirectory ( $ file -> getPathname ( ) ) ; } file_put_contents ( static :: $ resourcesPath . '/resources.lock' , json_encode ( $ data , JSON_PRETTY_PRINT ) ) ; }
Run composer post - install script
25,758
public function register ( Application $ app ) { $ this -> app = $ app ; $ app [ 'negotiator' ] = $ app -> share ( function ( $ app ) { return new \ Negotiation \ Negotiator ( ) ; } ) ; $ app [ 'language.negotiator' ] = $ app -> share ( function ( $ app ) { return new \ Negotiation \ LanguageNegotiator ( ) ; } ) ; $ customFormats = $ this -> customFormats ; $ app [ 'format.negotiator' ] = $ app -> share ( function ( $ app ) use ( $ customFormats ) { $ negotiator = new \ Negotiation \ FormatNegotiator ( ) ; foreach ( $ customFormats as $ name => $ mimeTypes ) { $ negotiator -> registerFormat ( $ name , $ mimeTypes , true ) ; } return $ negotiator ; } ) ; }
Register the services in the application .
25,759
public function onEarlyKernelRequest ( GetResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; foreach ( $ this -> customFormats as $ name => $ mimeTypes ) { $ request -> setFormat ( $ name , $ mimeTypes ) ; } }
Update the request with the given custom formats .
25,760
private function tpl ( ) : string { if ( interface_exists ( $ this -> type ) ) { return 'Return value of %s must implement interface %s, %s returned' ; } if ( class_exists ( $ this -> type ) ) { return 'Return value of %s must be an instance of %s, %s returned' ; } if ( $ this -> type == 'callable' ) { return 'Return value of %s must be %s, %s returned' ; } return 'Return value of %s must be of the type %s, %s returned' ; }
Return the template of the error message accoring to the expected type .
25,761
public static function getInstance ( $ graphUID = NULL , $ nodes = array ( ) , $ edges = array ( ) , $ directed = FALSE ) { if ( is_object ( static :: $ instance [ $ graphUID ] ) && is_a ( static :: $ instance [ $ graphUID ] , 'Graph' ) ) return static :: $ instance [ $ graphUID ] ; $ graph = new self ( $ nodes , $ edges , $ directed , $ graphUID ) ; if ( ! empty ( $ graphUID ) ) { static :: $ instance [ $ graphUID ] = & $ graph ; } return $ graph ; }
Returns and instantiated Instance of the graph class
25,762
public function getNode ( $ nodeId ) { static $ instance = array ( ) ; if ( isset ( $ instance [ $ nodeId ] ) ) return $ instance [ $ nodeId ] ; $ nodes = $ this -> nodeSet ; if ( empty ( $ nodes ) ) return NULL ; foreach ( $ nodes as $ node ) : if ( $ node -> getId ( ) == $ nodeId ) : $ instance [ $ nodeId ] = & $ node ; break ; endif ; endforeach ; return NULL ; }
Returns a node object if exists in graph
25,763
public function addEdge ( & $ nodeA , & $ nodeB , $ name = NULL , $ directed = TRUE , $ data = array ( ) , $ weight = 0 ) { $ edge = new Graph \ Edge ( $ nodeA , $ name , $ nodeB , $ data , $ directed , $ weight ) ; $ edgeId = $ edge -> getId ( ) ; if ( $ directed && ! in_array ( $ edgeId , $ this -> arcSet ) ) $ this -> arcSet [ ] = $ edgeId ; if ( isset ( $ this -> edgeSet [ $ edgeId ] ) ) { $ this -> edgeSet [ $ edgeId ] -> weight ++ ; $ edgeData = $ this -> edgeSet [ $ edgeId ] -> getData ( ) ; $ data = array_merge ( $ edgeData , $ data ) ; if ( ! $ directed && in_array ( $ edgeId , $ this -> arcSet ) ) $ this -> arcSet = array_diff ( $ this -> arcSet , array ( $ edgeId ) ) ; return true ; } if ( ! isset ( $ this -> edgeSet [ $ edgeId ] ) ) $ this -> edgeSet [ $ edgeId ] = & $ edge ; return true ; }
Adds an edge between two node endpoints .
25,764
public function removeNode ( $ nodeId ) { if ( isset ( $ this -> nodeSet [ $ nodeId ] ) ) unset ( $ this -> nodeSet [ $ nodeId ] ) ; return true ; }
Removes a node from the graph
25,765
public function removeEdge ( & $ head , & $ tail , $ directed = TRUE ) { if ( ! is_a ( $ head , "\Platform\Graph\Node" ) || ! is_a ( $ tail , "\Platform\Graph\Node" ) ) { throw new \ Platform \ Exception ( "Nodes used to create a new Edge must be instances of \Platform\Graph\Node" , PLATFORM_ERROR ) ; } $ _nodeIds = array ( $ head -> getId ( ) , $ tail -> getId ( ) ) ; $ edges = $ this -> edgeSet ; foreach ( $ edges as $ edge ) : echo $ edge -> getId ( ) . "<br />" ; if ( in_array ( $ edge -> getHead ( ) -> getId ( ) , $ _nodeIds ) && in_array ( $ edge -> getTail ( ) -> getId ( ) , $ _nodeIds ) ) : if ( ! $ directed ) : unset ( $ this -> edgeSet [ $ edge -> getId ( ) ] ) ; elseif ( $ edge -> getHead ( ) -> getId ( ) == reset ( $ _nodeIds ) && $ edge -> getTail ( ) -> getId ( ) == end ( $ _nodeIds ) ) : $ this -> arcSet = array_diff ( $ this -> arcSet , array ( $ edge -> getId ( ) ) ) ; unset ( $ this -> edgeSet [ $ edge -> getId ( ) ] ) ; endif ; endif ; endforeach ; return true ; }
Removes an Edge from the graph . Use removeArc to remove directed edges
25,766
public function createNode ( $ nodeId , $ data = array ( ) ) { $ node = new Graph \ Node ( $ nodeId , $ data ) ; $ node -> setGraph ( $ this ) ; $ this -> addNode ( $ node ) ; return $ node ; }
Creates and adds a Node to the graph if none already exists
25,767
public function addNode ( & $ node ) { if ( ! $ this -> isNode ( $ node ) ) { throw new \ Exception ( "Node must be an instance of Graph\Node" , PLATFORM_ERROR ) ; } $ nodedId = $ node -> getId ( ) ; if ( ! empty ( $ nodedId ) && ! isset ( $ this -> nodeSet [ $ node -> getId ( ) ] ) ) { $ this -> nodeSet [ $ node -> getId ( ) ] = & $ node ; } return $ this ; }
Adds a node to the current graph
25,768
public function destroy ( ) { if ( file_exists ( $ this -> _fileName ) ) { if ( unlink ( $ this -> _fileName ) ) { return true ; } else { return false ; } } else { return true ; } }
destroy a cache file
25,769
public function getCache ( ) { if ( ! file_exists ( $ this -> _fileName ) ) { $ this -> setCache ( ) ; } return unserialize ( ( $ this -> _uncompress ( file_get_contents ( $ this -> _fileName ) ) ) ) ; }
get cache content
25,770
public function setCache ( ) { if ( ! file_exists ( $ this -> _fileName ) ) { file_put_contents ( $ this -> _fileName , $ this -> _compress ( serialize ( $ this -> _content ) ) ) ; } $ timeAgo = time ( ) - filemtime ( $ this -> _fileName ) ; if ( $ timeAgo > $ this -> _time ) { file_put_contents ( $ this -> _fileName , $ this -> _compress ( serialize ( $ this -> _content ) ) ) ; } }
create the file cache
25,771
public function isDie ( ) { if ( $ this -> _time > 0 ) { $ die = false ; if ( ! file_exists ( $ this -> _fileName ) ) { $ die = true ; } else { $ timeAgo = time ( ) - filemtime ( $ this -> _fileName ) ; if ( $ timeAgo > $ this -> _time ) { $ die = true ; } } return $ die ; } else { return true ; } }
return true if the cache is too old
25,772
public static function get ( string $ name , array $ args = [ ] , $ persistant = false ) { if ( ! is_array ( static :: $ classes ) ) { throw new ArchException ( 'A static property $classes with an array of classes must be declared in class [' . __CLASS__ . ']' ) ; } if ( ! array_key_exists ( $ name , static :: $ classes ) ) { throw new ArchException ( 'Unknown object [' . $ name . ']' ) ; } return self :: buildClass ( static :: $ classes [ $ name ] , $ args , $ persistant ) ; }
Return an instance of corresponding object
25,773
public static function getClass ( string $ name ) { if ( ! isset ( static :: $ classes [ $ name ] ) ) { throw new ArchException ( 'Unable to find class from key [' . $ name . ']' ) ; } return static :: $ classes [ $ name ] ; }
Get full class name from key
25,774
public static function newObject ( string $ class , array $ args = [ ] , $ callGetClass = false ) { $ class = $ callGetClass ? static :: getClass ( $ class ) : $ class ; $ rc = new \ ReflectionClass ( $ class ) ; return $ rc -> newInstanceArgs ( $ args ) ; }
Instanciate a class dynamically
25,775
public function addValues ( array $ values ) { $ isMultiDimensional = 0 == count ( $ values ) || ( isset ( $ values [ 0 ] ) && is_array ( $ values [ 0 ] ) ) ; if ( $ isMultiDimensional ) { $ this -> insertRows = array_merge ( $ this -> insertRows , $ values ) ; } else { if ( count ( $ this -> insertRows ) > 0 ) { $ k = count ( $ this -> insertRows ) - 1 ; $ this -> insertRows [ $ k ] = array_replace ( $ this -> insertRows [ $ k ] , $ values ) ; } else { $ this -> insertRows = [ $ values ] ; } } return $ this ; }
Adds values to the statement .
25,776
public function create ( $ amount , $ currency , $ token , $ description = "" ) { $ service = new Request ( $ this -> apiKey ) ; $ transaction = new RequestTransaction ( ) ; $ transaction -> setAmount ( $ amount ) -> setCurrency ( $ currency ) -> setToken ( $ token ) -> setDescription ( $ description ) ; $ response = $ service -> create ( $ transaction ) ; return $ response ; }
Create new Transaction with a set of params
25,777
public static function populateXml ( $ data ) { $ isFile = ( is_file ( $ data ) ) ; libxml_use_internal_errors ( true ) ; if ( $ isFile === true ) { $ xml = simplexml_load_file ( $ data , '\SimpleXMLElement' ) ; } else { $ xml = simplexml_load_string ( $ data , '\SimpleXMLElement' ) ; } if ( empty ( $ xml ) ) { $ errors = [ ] ; if ( $ isFile === true ) { $ errors [ ] = $ data ; } foreach ( libxml_get_errors ( ) as $ error ) { $ errors [ ] = 'XML: ' . $ error -> message ; } throw new Exception ( 'XML file could not be loaded : ' . "\n" . implode ( "\n" , $ errors ) ) ; } return $ xml ; }
Reads a XML file
25,778
public function getDesignModules ( ) { $ iterator = $ this -> createFinder ( ) -> in ( $ this -> getAbsoluteDesignFolder ( ) ) -> directories ( ) ; $ modules = [ ] ; foreach ( $ iterator as $ file ) { if ( file_exists ( $ file -> getRealPath ( ) . '/index.ss' ) ) { $ modules [ ] = new DesignModule ( $ file -> getRealPath ( ) ) ; } } return $ modules ; }
Gets all of the design modules as objects
25,779
public function getDesignModule ( $ name ) { foreach ( $ this -> getDesignModules ( ) as $ module ) { if ( $ module -> getName ( ) == $ name ) { return $ module ; } } return false ; }
Gets a specific design module as an object by its name
25,780
public function isMatch ( $ url ) { $ url = trim ( $ url ) ; if ( $ url == $ this -> pattern ) return true ; $ parts = explode ( "/" , trim ( $ url , "/" ) ) ; $ pattern = explode ( "/" , trim ( $ this -> pattern , "/" ) ) ; if ( count ( $ parts ) != count ( $ pattern ) ) return false ; $ regex = array ( ) ; foreach ( $ pattern as $ key => $ url_item ) { if ( preg_match_all ( "|{(.*):(.*)}|" , $ url_item , $ matches ) ) { if ( in_array ( reset ( $ matches [ 2 ] ) , array ( "int" , "bool" , "alpha" , "float" , "date" ) ) ) { switch ( reset ( $ matches [ 2 ] ) ) { case "int" : $ regex [ ] = "[0-9]+" ; break ; case "bool" : $ regex [ ] = "(true|false)" ; break ; case "alpha" : $ regex [ ] = "[A-Za-z]+" ; break ; case "float" : $ regex [ ] = "[+-]?\d+(\.\d+)?" ; break ; case "date" : $ regex [ ] = "(19?[0-9]{2}|20[0-1][0-4])-(0?[1-9]|1[0-2])-([0-2]?[0-9]|3[0-1])" ; break ; } $ this -> params [ reset ( $ matches [ 1 ] ) ] = $ parts [ $ key ] ; } } elseif ( preg_match_all ( "|{(.*)}|" , $ url_item , $ matches ) ) { $ regex [ ] = ".*" ; $ this -> params [ reset ( $ matches [ 1 ] ) ] = $ parts [ $ key ] ; } else $ regex [ ] = $ url_item ; } return ( bool ) preg_match ( sprintf ( "/^%s$/" , implode ( "\/" , $ regex ) ) , trim ( $ url , "/" ) ) ; }
Match url to specific url pattern
25,781
public function getConfig ( string $ id ) : Config { $ this -> configs [ $ id ] = $ this -> configs [ $ id ] ?? $ this -> registerConfig ( $ id ) ; return $ this -> configs [ $ id ] ; }
Returns a Config instance for specific checker . Instantiate if necessary .
25,782
protected function registerConfig ( string $ id ) : Config { $ definition = $ this -> definitions [ $ id ] ?? [ ] ; $ config = new Config ( $ definition ) ; return apply_filters ( static :: HOOK , $ config , $ definition , $ id ) ; }
Instantiate a Config instance for specific checker .
25,783
public static function get ( $ pUrl , $ pParams = array ( ) , $ pRelative = true ) { if ( strpos ( $ pUrl , '*/' ) !== false ) { if ( self :: $ _request === NULL ) { self :: setRequest ( ) ; } $ pUrl = str_replace ( '*/*/' , self :: $ _request -> getModule ( ) . DS . self :: $ _request -> getView ( ) , $ pUrl ) ; $ pUrl = str_replace ( '*/' , self :: $ _request -> getModule ( ) . DS , $ pUrl ) ; } if ( Agl :: isModuleLoaded ( Agl :: AGL_MORE_POOL . '/locale/locale' ) ) { return Agl :: getSingleton ( Agl :: AGL_MORE_POOL . '/locale' ) -> getUrl ( $ pUrl , $ pParams , $ pRelative ) ; } if ( ! $ pUrl ) { if ( $ pRelative ) { return ROOT ; } return self :: getHost ( ROOT ) ; } if ( strpos ( $ pUrl , Agl :: APP_PUBLIC_DIR ) === false ) { if ( is_array ( $ pParams ) and ! empty ( $ pParams ) ) { $ params = array ( ) ; foreach ( $ pParams as $ key => $ value ) { $ params [ ] = $ key . DS . $ value ; } $ url = $ pUrl . DS . implode ( DS , $ params ) . DS ; } else if ( is_string ( $ pParams ) and $ pParams ) { $ url = $ pUrl . DS . $ pParams . DS ; } else { $ url = $ pUrl . DS ; } if ( $ pRelative ) { return ROOT . $ url ; } return self :: getHost ( ROOT . $ url ) ; } if ( $ pRelative ) { return ROOT . $ pUrl ; } return self :: getHost ( ROOT . $ pUrl ) ; }
Return a formated URL with module view action and parameters .
25,784
public static function getCurrent ( $ pRelative = true , array $ pNewParams = array ( ) ) { if ( self :: $ _request === NULL ) { self :: setRequest ( ) ; } $ request = self :: $ _request ; $ module = $ request -> getModule ( ) ; $ view = $ request -> getView ( ) ; $ params = str_replace ( $ module . DS . $ view , '' , $ request -> getReq ( ) ) ; if ( ! empty ( $ pNewParams ) ) { $ newParams = array ( ) ; foreach ( $ pNewParams as $ key => $ value ) { $ newParams [ ] = $ key . DS . $ value ; } $ params .= DS . implode ( DS , $ newParams ) ; } $ params = trim ( $ params , DS ) ; if ( $ module == $ request :: DEFAULT_MODULE and $ view == $ request :: DEFAULT_VIEW and ! $ params ) { return self :: get ( '' , $ params , $ pRelative ) ; } return self :: get ( $ module . DS . $ view , $ params , $ pRelative ) ; }
Return the current URL with optional additional params .
25,785
public static function getSkin ( $ pUrl , $ pRelative = true ) { $ url = Agl :: APP_PUBLIC_DIR . ViewInterface :: APP_HTTP_SKIN_DIR . DS . $ pUrl ; if ( $ pRelative ) { return ROOT . $ url ; } return self :: getHost ( ROOT . $ url ) ; }
Get the skin base URL .
25,786
public static function getPublic ( $ pUrl , $ pRelative = true ) { $ url = Agl :: APP_PUBLIC_DIR . $ pUrl ; if ( $ pRelative ) { return ROOT . $ url ; } return self :: getHost ( ROOT . $ url ) ; }
Get the public base URL .
25,787
public static function getHost ( $ pPath = '' , $ pHost = '' ) { if ( ! $ pHost ) { $ pHost = $ _SERVER [ 'HTTP_HOST' ] ; } return self :: getProtocol ( ) . $ pHost . $ pPath ; }
Get the base URL with host name and protocol .
25,788
public function get ( ) { $ disks = [ ] ; $ result = $ this -> connection -> newQuery ( ) -> from ( Classes :: WIN32_LOGICALDISK ) -> get ( ) ; foreach ( $ result as $ disk ) { $ disks [ ] = new HardDisk ( $ disk ) ; } return $ disks ; }
Returns an array of all hard disks on the computer .
25,789
private static function getStockWidgets ( ) { $ reflectionClass = new \ ReflectionClass ( get_class ( ) ) ; $ classNames = array ( ) ; foreach ( $ reflectionClass -> getConstants ( ) as $ name => $ value ) if ( preg_match ( '/^STOCK_WP/' , $ name ) ) $ classNames [ ] = $ value ; return $ classNames ; }
By means of class reflection gets a list of all the classnames of the stock widgets
25,790
protected function spliceIntoPosition ( $ position , $ value ) { $ segments = explode ( ' ' , $ this -> pattern ) ; $ segments [ $ position - 1 ] = $ value ; return $ this -> cron ( implode ( ' ' , $ segments ) ) ; }
Splice the given value into the given position of the expression .
25,791
private function createPatternWithVariables ( ) { $ variables = [ $ this -> getMinute ( ) , $ this -> getHour ( ) , $ this -> getDayOfMounth ( ) , $ this -> getMounth ( ) , $ this -> getDayOfWeek ( ) , $ this -> getYear ( ) , ] ; return join ( ' ' , $ variables ) ; }
if pattern is null create patten with private variables
25,792
public static function run ( $ routes ) { self :: setAppPath ( ) ; self :: setFrameworkPath ( ) ; self :: exception ( ) ; self :: events ( ) ; self :: model ( ) ; self :: controller ( ) ; self :: link ( ) ; if ( Component :: isOn ( 'database' ) ) { self :: seed ( ) ; } self :: filtes ( ) ; self :: alias ( ) ; Environment :: ini ( ) ; self :: mails ( ) ; self :: routes ( $ routes ) ; self :: commands ( ) ; }
Get all required App files .
25,793
protected static function fetch ( $ pattern , $ app = true ) { if ( $ app ) { return glob ( self :: $ appPath . $ pattern . '/*.php' ) ; } else { return glob ( self :: $ frameworkPath . $ pattern . '/*.php' ) ; } }
Fetch files of folder .
25,794
protected static function middleware ( ) { foreach ( self :: fetch ( 'http/middleware' ) as $ file ) { Bus :: need ( $ file ) ; } Middleware :: ini ( ) ; }
Require and call middleware classes .
25,795
protected static function routes ( $ routes ) { if ( $ routes ) { self :: middleware ( ) ; Bus :: need ( self :: $ appPath . 'http/Routes.php' ) ; Routes :: run ( ) ; } }
Require files of Routes .
25,796
protected static function events ( ) { foreach ( self :: fetch ( 'app/events' , false ) as $ file ) { Bus :: need ( $ file ) ; } Event :: register ( ) ; }
Require files of Console .
25,797
protected static function mails ( ) { if ( is_dir ( root ( ) . 'app/mails' ) ) { foreach ( self :: fetch ( 'app/mails' , false ) as $ file ) { need ( $ file ) ; } } }
Require files of Mail if exists .
25,798
private function getOptionalParam ( $ s_paramName , $ am_writerConf ) { $ m_paramValue = null ; if ( array_key_exists ( $ s_paramName , $ am_writerConf ) ) { $ m_paramValue = $ am_writerConf [ $ s_paramName ] ; } return $ m_paramValue ; }
Returns value of a parameter if present null otherwise
25,799
public function add ( string $ key , $ value ) { $ current = $ this -> get ( $ key , [ ] ) ; $ adds = is_array ( $ value ) ? $ value : [ $ value ] ; $ this -> set ( $ key , array_merge ( $ current , array_values ( $ adds ) ) ) ; }
Add Values To Key Array