idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
49,900
public function delete ( $ id ) { $ result = null ; $ this -> hook -> attach ( 'module.backup.delete.before' , $ id , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } $ result = $ this -> deleteZip ( $ id ) ; if ( $ result ) { $ this -> db -> delete ( 'backup' , array ( 'backup_id' => $ id ) ) ; } $ this -> h...
Deletes a backup from disk and database
49,901
protected function deleteZip ( $ backup_id ) { $ backup = $ this -> get ( $ backup_id ) ; if ( empty ( $ backup [ 'path' ] ) ) { return false ; } $ file = gplcart_file_absolute ( $ backup [ 'path' ] ) ; return file_exists ( $ file ) && unlink ( $ file ) ; }
Deletes a backup ZIP archive
49,902
public function exists ( $ id , $ version = null ) { $ list = $ this -> getList ( array ( 'id' => $ id , 'version' => $ version ) ) ; return ! empty ( $ list ) ; }
Whether a backup already exists
49,903
protected function callHandler ( $ handler_id , $ method , array $ arguments ) { try { $ handlers = $ this -> getHandlers ( ) ; return Handler :: call ( $ handlers , $ handler_id , $ method , $ arguments ) ; } catch ( Exception $ ex ) { return $ ex -> getMessage ( ) ; } }
Cal a handler
49,904
public function diff ( Snapshot $ other ) { return new self ( $ this -> _time - $ other -> getTime ( ) , $ this -> _memoryUsage - $ other -> getMemoryUsage ( ) , $ this -> _realMemoryUsage - $ other -> getRealMemoryUsage ( ) , ( $ this -> _memoryUsagePeak + $ other -> getMemoryUsagePeak ( ) ) / 2 , ( $ this -> _realMem...
Subtracts a snapshot from another one .
49,905
public static function create ( ) { return new self ( microtime ( true ) , memory_get_usage ( false ) , memory_get_usage ( true ) , memory_get_peak_usage ( false ) , memory_get_peak_usage ( true ) ) ; }
Creates a new snapshot based on current PHP environment metrics
49,906
function ReportSiteAction ( Site $ site , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: Site ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logSite = new LogSite ( ) ; $ logSite -> SetLogItem ( $ logItem ) ; $ logSite -> SetSite ( $ site ) ;...
Reports a site action to the log
49,907
function ReportPageAction ( Page $ page , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: Page ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logPage = new LogPage ( ) ; $ logPage -> SetLogItem ( $ logItem ) ; $ logPage -> SetPage ( $ page ) ;...
Reports a page action with dependencies to the log
49,908
function ReportAreaAction ( Area $ area , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: Area ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logArea = new LogArea ( ) ; $ logArea -> SetLogItem ( $ logItem ) ; $ logArea -> SetArea ( $ area ) ;...
Reports an area action with dependencies to the log
49,909
function ReportLayoutAction ( Layout $ layout , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: Layout ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logLayout = new LogLayout ( ) ; $ logLayout -> SetLogItem ( $ logItem ) ; $ logLayout -> SetL...
Reports a layout action with dependencies to the log
49,910
function ReportContainerAction ( Container $ container , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: Container ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logContainer = new LogContainer ( ) ; $ logContainer -> SetContainer ( $ containe...
Reports a container action with dependencies to the log
49,911
function ReportContentAction ( Content $ content , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: Content ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logContent = new LogContent ( ) ; $ logContent -> SetLogItem ( $ logItem ) ; $ logContent...
Reports a content action with dependencies to the log
49,912
function ReportMemberAction ( Member $ member , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: Member ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logMember = new LogMember ( ) ; $ logMember -> SetLogItem ( $ logItem ) ; $ logMember -> SetM...
Reports a member action to the log
49,913
function ReportMemberGroupAction ( Membergroup $ memberGroup , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: MemberGroup ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logMemberGroup = new LogMembergroup ( ) ; $ logMemberGroup -> SetLogItem ...
Reports a member group action to the log
49,914
function ReportUserAction ( User $ user , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: User ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logUser = new LogUser ( ) ; $ logUser -> SetLogItem ( $ logItem ) ; $ logUser -> SetUser ( $ user ) ;...
Reports a user action to the log
49,915
function ReportUserGroupAction ( Usergroup $ userGroup , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: UserGroup ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logUserGroup = new LogUsergroup ( ) ; $ logUserGroup -> SetLogItem ( $ logItem ) ...
Reports a user group action to the log
49,916
function ReportTemplateAction ( $ moduleType , $ template , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: Template ( ) , $ action ) ; $ logTemplate = new LogTemplate ; $ logTemplate -> SetLogItem ( $ logItem ) ; $ logTemplate -> SetModuleType ( $ moduleType ) ; $ logTemplate ->...
Reports an action on a module template
49,917
private function CreateLogItem ( Enums \ ObjectType $ objType , Enums \ Action $ action ) { $ this -> DeleteOldLogItems ( ) ; $ item = new LogItem ( ) ; $ item -> SetChanged ( Date :: Now ( ) ) ; $ item -> SetAction ( ( string ) $ action ) ; $ item -> SetObjectType ( ( string ) $ objType ) ; $ item -> SetUser ( $ this ...
Creates a log item
49,918
private function DeleteOldLogItems ( ) { $ days = SettingsProxy :: Singleton ( ) -> Settings ( ) -> GetLogLifetime ( ) ; $ deleteBefore = Date :: Now ( ) ; $ deleteBefore -> AddDays ( - $ days ) ; $ tblLogItem = LogItem :: Schema ( ) -> Table ( ) ; $ sql = Access :: SqlBuilder ( ) ; $ where = $ sql -> LT ( $ tblLogItem...
Deletes log items older then the given amount of days
49,919
public static function classNameShort ( $ class ) { $ className = self :: className ( $ class ) ; $ position = strrpos ( $ className , '\\' ) ; $ name = substr ( $ className , $ position + 1 ) ; return $ name ; }
Returns only the class name
49,920
public static function classHasMethod ( $ method , $ class ) { $ methods = self :: classMethods ( $ class ) ; if ( ! in_array ( $ method , $ methods ) ) { return false ; } return true ; }
Check if class has method
49,921
public static function hash ( $ data , $ file = false ) { $ hasher = new \ Nuki \ Handlers \ Security \ Hasher ( self :: getAppAlgorithm ( ) , self :: getAppKey ( ) ) ; return $ hasher -> hash ( $ data , $ file ) ; }
Hash by data or filename
49,922
public static function encrypt ( $ data ) : Encrypted { $ crypter = new Crypter ( ) ; return $ crypter -> encrypt ( $ data , self :: getAppKey ( ) ) ; }
Encrypt data and return an encrypter object
49,923
public static function decrypt ( $ data ) : string { $ crypter = new Crypter ( ) ; return $ crypter -> decrypt ( $ data , self :: getAppKey ( ) ) ; }
Decrypt data and return the decrypted value
49,924
public static function loadCoreView ( string $ name ) { $ base = __DIR__ . '/../../Views/' ; if ( ! file_exists ( $ base . $ name . '.view' ) ) { throw new \ Nuki \ Exceptions \ Base ( 'The view file "' . $ name . '" does not exist.' ) ; } return file_get_contents ( $ base . $ name . '.view' ) ; }
Load the contents of a core view file
49,925
public static function makeFromInteger ( $ integer ) { if ( $ integer == 0 ) return static :: $ chars [ 0 ] ; $ number = abs ( $ integer ) ; if ( $ integer < 0 ) throw new \ InvalidArgumentException ( "Can not encode for negative integers" ) ; $ string = '' ; $ base = strlen ( static :: $ chars ) ; while ( $ number > 0...
Make a unique string from an Integer
49,926
public static function decodeToInteger ( $ string ) { $ stringLength = strlen ( $ string ) ; $ baseLength = strlen ( static :: $ chars ) ; $ id = 0 ; for ( $ i = 0 ; $ i < $ stringLength ; $ i ++ ) { $ pos = strpos ( static :: $ chars , $ string [ $ i ] ) ; $ id = ( $ id * $ baseLength ) + $ pos ; } return $ id ; }
Decode the encoded string to Integer
49,927
public function getMenu ( DTO $ dto = null ) { if ( ! $ menu = $ this -> SystemCache -> get ( 'cms-menu' ) ) { $ menu = array ( ) ; if ( $ dto === null ) $ dto = new DTO ( ) ; $ dto -> setOrderBy ( 'SortOrder' , 'ASC' ) ; $ dto -> setParameter ( 'FlattenChildren' , false ) ; $ dto -> setParameter ( 'Enabled' , true ) ;...
Returns an array that represents the CMS Navigation menu
49,928
public function asError ( $ status = self :: INTERNAL_ERROR ) { if ( $ this -> error_views ) { $ stream = $ this -> error_views -> getStream ( $ status ) ; } else { $ stream = null ; } return Response :: error ( $ status , $ this -> data , $ stream ) ; }
return a response with error number .
49,929
protected function switchContentType ( $ data ) { switch ( $ this -> format ) { case 'application/json' : $ data = json_encode ( is_object ( $ data ) ? ( array ) $ data : $ data ) ; break ; case 'application/xml' : $ data = is_object ( $ data ) ? ( string ) $ data : $ data ; break ; default : $ data = ( string ) $ data...
Switch content type
49,930
public function extraValidation ( $ data , $ performPhoneValidation = true ) { $ this -> messages = new MessageBag ; if ( ( ! $ this -> userRepository -> validatePhoneNumber ( $ data [ 'phone_number' ] ) ) && ( $ performPhoneValidation ) ) { $ this -> messages -> add ( 'phone_number' , 'There is a problem with your pho...
Perform extra validation
49,931
public function toSQL ( Parameters $ params , bool $ inner_clause ) { if ( $ inner_clause ) return '(' . $ this -> getSQL ( ) . ')' ; return $ this -> getSQL ( ) ; }
Add a custom SQL string to the query
49,932
public static function redis ( ) { $ pid = getmypid ( ) ; if ( self :: $ pid !== $ pid ) { self :: $ redis = null ; self :: $ pid = $ pid ; } if ( ! is_null ( self :: $ redis ) ) { return self :: $ redis ; } $ server = self :: $ redisServer ; if ( empty ( $ server ) ) { $ server = 'localhost:6379' ; } if ( is_array ( $...
Return an instance of the Redis class instantiated for Resque .
49,933
public static function runAll ( $ value ) { foreach ( get_class_methods ( __CLASS__ ) as $ method ) { if ( strpos ( $ method , 'run' ) === 0 ) { continue ; } $ value = self :: $ method ( $ value ) ; } return $ value ; }
Runs all converter functions
49,934
public function addInsert ( array $ rows ) : self { if ( ! empty ( $ rows ) && ! is_array ( reset ( $ rows ) ) ) { $ rows = [ $ rows ] ; } foreach ( $ rows as $ index => $ row ) { if ( ! is_array ( $ row ) ) { return $ this -> handleException ( InvalidArgumentException :: create ( 'Argument $rows[' . $ index . ']' , $ ...
Adds a row to insert to the table .
49,935
public function addInsertFromSelect ( $ columns , $ selectQuery = null ) : self { if ( $ selectQuery === null ) { $ selectQuery = $ columns ; $ columns = null ; } if ( $ columns !== null ) { if ( ! is_array ( $ columns ) ) { return $ this -> handleException ( InvalidArgumentException :: create ( 'Argument $columns' , $...
Adds an instruction that the query should insert values to the table from the select query .
49,936
final public function validate ( ) : bool { if ( $ this -> _tokenRequired && ! $ this -> _tokenOk ) { App :: $ Session -> getFlashBag ( ) -> add ( 'warning' , __ ( 'Hack attention: security token is wrong!' ) ) ; return false ; } $ rules = $ this -> rules ( ) ; $ defaultAttr = $ this -> getAllProperties ( ) ; $ success...
Validate defined rules in app
49,937
public function getAllProperties ( ) : ? array { $ properties = null ; foreach ( $ this as $ property => $ value ) { if ( Str :: startsWith ( '_' , $ property ) ) { continue ; } $ properties [ $ property ] = $ value ; } return $ properties ; }
Get all properties for current model in key = > value array
49,938
public function clearProperties ( ) : void { foreach ( $ this as $ property => $ value ) { if ( ! Str :: startsWith ( '_' , $ property ) ) { $ this -> { $ property } = null ; } } }
Cleanup all public model properties
49,939
final public function getValidationRule ( $ field ) : array { $ rules = $ this -> rules ( ) ; $ response = [ ] ; foreach ( $ rules as $ rule ) { if ( Any :: isArray ( $ rule [ 0 ] ) ) { foreach ( $ rule [ 0 ] as $ tfield ) { if ( $ tfield == $ field ) { $ response [ $ rule [ 1 ] ] = $ rule [ 2 ] ; } } } else { if ( $ r...
Get validation rules for field
49,940
public function attach ( $ serviceClassName , array $ options = [ ] ) { if ( true === isset ( $ this -> service [ $ serviceClassName ] ) ) { throw new DuplicateEntryException ( 'The service "' . $ serviceClassName . '" was already attached to the service factory.' , 1456418859 ) ; } $ this -> currentService = $ service...
Will attach a service to this factory .
49,941
public function get ( $ serviceClassName ) { if ( false === $ this -> hasBeenInitialized ) { throw new InitializationNotSetException ( 'You can get a service instance only when the service factory has been initialized.' , 1456419587 ) ; } if ( false === $ this -> has ( $ serviceClassName ) ) { throw new EntryNotFoundEx...
Returns the wanted service if it was previously registered .
49,942
public function with ( $ serviceClassName ) { if ( false === $ this -> has ( $ serviceClassName ) ) { throw new Exception ( 'You cannot use the function "' . __FUNCTION__ . '" on a service which was not added to the factory (service used: "' . $ serviceClassName . '").' , 1459425398 ) ; } $ this -> currentService = $ s...
Resets the current service value to the given service allowing the usage of the function setOption with this service .
49,943
public function getOption ( $ optionName ) { return ( isset ( $ this -> service [ $ this -> currentService ] [ 'options' ] [ $ optionName ] ) ) ? $ this -> service [ $ this -> currentService ] [ 'options' ] [ $ optionName ] : null ; }
Returns an option for the current service . If the option is not found null is returned .
49,944
public function initialize ( ) { if ( true === $ this -> hasBeenInitialized ) { return ; } $ this -> hasBeenInitialized = true ; foreach ( $ this -> service as $ service ) { list ( $ serviceClassName , $ serviceOptions ) = $ this -> manageServiceData ( $ service ) ; $ this -> serviceInstances [ $ serviceClassName ] = $...
Initializes every single service which was added in this instance .
49,945
public function runServicesFromEvent ( $ serviceEvent , $ eventMethodName , AbstractServiceDTO $ dto ) { if ( false === $ this -> hasBeenInitialized ) { return ; } $ this -> checkServiceEvent ( $ serviceEvent ) ; $ this -> checkServiceEventMethodName ( $ serviceEvent , $ eventMethodName ) ; $ serviceInstances = $ this ...
Will loop on each registered service in this factory and check if they use the requested event . If they do the event is dispatched .
49,946
protected function checkServiceEvent ( $ serviceEvent ) { if ( false === isset ( self :: $ servicesChecked [ $ serviceEvent ] ) ) { self :: $ servicesChecked [ $ serviceEvent ] = [ ] ; if ( false === in_array ( ServiceEventInterface :: class , class_implements ( $ serviceEvent ) ) ) { throw new WrongInheritanceExceptio...
Will check if the class of the service event is correct and implements the correct interface .
49,947
protected function checkServiceEventMethodName ( $ serviceEvent , $ eventMethodName ) { if ( false === in_array ( $ eventMethodName , self :: $ servicesChecked [ $ serviceEvent ] ) ) { $ eventClassReflection = ReflectionService :: get ( ) -> getClassReflection ( $ serviceEvent ) ; self :: $ servicesChecked [ $ serviceE...
Will check if the given method exists in the service event .
49,948
protected function getServicesFromEvent ( $ serviceEvent ) { if ( false === isset ( $ this -> servicesEvents [ $ serviceEvent ] ) ) { $ servicesInstances = [ ] ; foreach ( $ this -> serviceInstances as $ serviceInstance ) { if ( $ serviceInstance instanceof $ serviceEvent ) { $ servicesInstances [ ] = $ serviceInstance...
Will loop trough all the services instance and get the ones which use the given event .
49,949
private function migrate ( $ outputLog ) { try { DB :: connection ( ) -> getPdo ( ) ; DB :: unprepared ( file_get_contents ( 'core/database.sql' ) ) ; } catch ( Exception $ e ) { return $ this -> response ( $ e -> getMessage ( ) ) ; } return $ this -> seed ( $ outputLog ) ; }
Run the migration and call the seeder .
49,950
private function sqlite ( $ outputLog ) { if ( DB :: connection ( ) instanceof SQLiteConnection ) { $ database = DB :: connection ( ) -> getDatabaseName ( ) ; if ( ! file_exists ( $ database ) ) { touch ( $ database ) ; DB :: reconnect ( Config :: get ( 'database.default' ) ) ; } $ outputLog -> write ( 'Using SqlLite d...
check database type . If SQLite then create the database file .
49,951
public function build ( StorageFacilityInfo $ sfInfo ) { $ storageFacility = $ this -> ApplicationContext -> object ( $ sfInfo -> ObjectRef ) ; return $ storageFacility ; }
Get a storage facility prototype instance from the application context
49,952
public static function compareFiles ( $ file1 , $ file2 , $ compareCharacters = false ) { return self :: compare ( file_get_contents ( $ file1 ) , file_get_contents ( $ file2 ) , $ compareCharacters ) ; }
Returns the diff for two files .
49,953
public static function toString ( $ diff , $ separator = "\n" ) { $ string = '' ; foreach ( $ diff as $ line ) { switch ( $ line [ 1 ] ) { case self :: UNMODIFIED : $ string .= ' ' . $ line [ 0 ] ; break ; case self :: DELETED : $ string .= '- ' . $ line [ 0 ] ; break ; case self :: INSERTED : $ string .= '+ ' . $ lin...
Returns a diff as a string where unmodified lines are prefixed by deletions are prefixed by - and insertions are prefixed by + .
49,954
public static function toTable ( $ diff , $ indentation = '' , $ separator = '<br />' ) { $ html = $ indentation . "<table class=\"diff\">\n" ; $ index = 0 ; while ( $ index < count ( $ diff ) ) { switch ( $ diff [ $ index ] [ 1 ] ) { case self :: UNMODIFIED : $ leftCell = self :: getCellContent ( $ diff , $ indentatio...
Returns a diff as an HTML table .
49,955
public function checkChars ( $ value ) { if ( strlen ( $ value ) != 8 ) { if ( strpos ( $ value , 'X' ) !== false ) { return false ; } } return parent :: checkChars ( $ value ) ; }
Allows X on length of 8 chars
49,956
public function submitSubscribe ( $ listID , $ composedItem = [ ] ) { $ results = $ this -> mailChimp -> call ( "lists/subscribe" , [ 'id' => $ listID , 'email' => [ 'email' => $ composedItem [ 'email' ] [ 'email' ] ] , 'merge_vars' => $ composedItem [ 'merge_vars' ] , 'double_optin' => false , 'update_existing' => tru...
Make single signup submission to MailChimp . Typically used for resubscribes .
49,957
public function composeSubscriberSubmission ( $ newSubscribers = [ ] ) { $ composedSubscriberList = [ ] ; foreach ( $ newSubscribers as $ newSubscriberCount => $ newSubscriber ) { if ( isset ( $ newSubscriber [ 'birthdate' ] ) && is_int ( $ newSubscriber [ 'birthdate' ] ) ) { $ newSubscriber [ 'birthdate_timestamp' ] =...
Format email list to meet MailChimp API requirements for batchSubscribe
49,958
public function memberInfo ( $ email , $ listID ) { $ mailchimpStatus = $ this -> mailChimp -> call ( "/lists/member-info" , [ 'id' => $ listID , 'emails' => [ 0 => [ 'email' => $ email ] ] ] ) ; return $ mailchimpStatus ; }
Gather account information froma specific list
49,959
private function match ( $ request ) { $ route = $ this -> router -> match ( $ request -> getUri ( ) -> getPath ( ) , $ request -> getMethod ( ) ) ; if ( ! $ route ) { return $ this -> next ? $ this -> next -> __invoke ( $ request ) : null ; } return $ this -> dispatch ( $ request , $ route ) ; }
matches the route!
49,960
private function dispatch ( $ request , $ route ) { if ( $ route -> matched ( ) ) { $ request = $ request -> withPathToMatch ( $ route -> matched ( ) , $ route -> trailing ( ) ) ; } return $ this -> dispatcher -> withRoute ( $ route ) -> __invoke ( $ request ) ; }
execute the dispatcher and filters using blank new web application .
49,961
public function ParseToken ( $ text , $ startPos , & $ endPos ) { $ endPos = $ startPos + strlen ( self :: Start ) ; $ tokenString = $ this -> ExtractTokenString ( $ text , $ startPos , $ endPos ) ; if ( ! $ tokenString ) { return null ; } $ nextStop = 0 ; $ type = $ this -> ParseType ( $ tokenString , $ nextStop ) ; i...
Tries to parse a token beginning on the start marker
49,962
private function ParseFilters ( $ tokenString , $ nextStop ) { $ filters = array ( ) ; if ( $ nextStop === false ) { return $ filters ; } $ trimString = trim ( substr ( $ tokenString , $ nextStop ) ) ; if ( $ trimString == '' ) { return $ filters ; } if ( ! Str :: StartsWith ( self :: FilterSeparator , $ trimString ) )...
Parses the filters
49,963
protected function RemovalObject ( ) { $ id = Request :: PostData ( 'delete' ) ; return $ id ? Usergroup :: Schema ( ) -> ByID ( $ id ) : null ; }
The user group required for deleting
49,964
protected function CanEdit ( Usergroup $ group ) { return self :: Guard ( ) -> Allow ( BackendAction :: Edit ( ) , $ group ) && self :: Guard ( ) -> Allow ( BackendAction :: UseIt ( ) , new UsergroupForm ( ) ) ; }
True if group can be edited
49,965
protected function ModuleLockFormUrl ( Usergroup $ group ) { $ args = array ( 'usergroup' => $ group -> GetID ( ) ) ; return BackendRouter :: ModuleUrl ( new ModuleLockForm ( ) , $ args ) ; }
Gets the url for the module lock
49,966
public function behaviors ( ) { return [ 'rbac' => [ 'class' => Yii :: $ app -> cmgCore -> getRbacFilterClass ( ) , 'actions' => [ 'index' => [ 'permission' => CoreGlobal :: PERM_USER ] , 'update' => [ 'permission' => CoreGlobal :: PERM_USER ] ] ] , 'verbs' => [ 'class' => VerbFilter :: className ( ) , 'actions' => [ '...
yii \ base \ Component
49,967
public function getVariable ( $ name , $ default = NULL ) { return isset ( $ this -> conf [ $ name ] ) ? $ this -> conf [ $ name ] : $ default ; }
Returns a persistent variable .
49,968
private function getAccessTokenFromAuthorizationCode ( $ code ) { if ( $ this -> getVariable ( 'access_token_uri' ) && $ this -> getVariable ( 'client_id' ) && $ this -> getVariable ( 'client_secret' ) ) { return json_decode ( $ this -> makeRequest ( $ this -> getVariable ( 'access_token_uri' ) , 'POST' , array ( 'gran...
Get access token from OAuth2 . 0 token endpoint with authorization code .
49,969
protected function makeRequest ( $ path , $ method = 'GET' , $ params = array ( ) , $ ch = NULL ) { if ( ! $ ch ) $ ch = curl_init ( ) ; $ opts = self :: $ CURL_OPTS ; if ( $ params ) { switch ( $ method ) { case 'GET' : $ path .= '?' . http_build_query ( $ params , NULL , '&' ) ; break ; default : if ( $ this -> getVa...
Makes an HTTP request .
49,970
protected function setCookieFromSession ( $ session = NULL ) { if ( ! $ this -> getVariable ( 'cookie_support' ) ) return ; $ cookie_name = $ this -> getSessionCookieName ( ) ; $ value = 'deleted' ; $ expires = time ( ) - 3600 ; $ base_domain = $ this -> getVariable ( 'base_domain' , self :: DEFAULT_BASE_DOMAIN ) ; if ...
Set a JS Cookie based on the _passed in_ session .
49,971
protected function generateSignature ( $ params , $ secret ) { ksort ( $ params ) ; $ base_string = '' ; foreach ( $ params as $ key => $ value ) { $ base_string .= $ key . '=' . $ value ; } $ base_string .= $ secret ; return md5 ( $ base_string ) ; }
Generate a signature for the given params and secret .
49,972
public function toMinutes ( ) { $ time = $ this -> get ( ) ; if ( ! $ time ) { $ time = '00:00' ; } else { $ time = sprintf ( '%02d:%02d' , ( int ) ( floor ( $ time / 60 ) ) , ( int ) ( $ time % 60 ) ) ; } return $ this ; }
Convert an int as seconds into Minutes .
49,973
public function createBlade ( $ views , $ cache ) { $ this -> _blade = new Blade ( $ views , $ cache ) ; $ this -> _view = $ this -> _blade -> view ( ) ; }
Creates a new Blade instance .
49,974
public function compile ( $ path ) { $ this -> parseContent ( $ path , $ this -> _data ) ; return $ this -> _factory -> render ( ) ; }
Compiles the view .
49,975
public function with ( $ key , $ value = null ) { if ( is_array ( $ key ) ) { $ this -> _data = array_merge ( $ this -> _data , $ key ) ; } else { $ this -> _data [ $ key ] = $ value ; } return $ this ; }
Adds data to pass onto the view .
49,976
public static function renderView ( $ path , $ dataName = '' , $ data = '' ) { $ view = new self ( ) ; if ( ! empty ( $ dataName ) ) { $ view -> with ( $ dataName , $ data ) ; } return $ view -> render ( $ path , false ) ; }
Static function to render a view .
49,977
private function parseContent ( $ path , $ data ) { $ path = str_replace ( '.' , '/' , $ path ) ; $ this -> _factory = $ this -> _view -> make ( $ path , $ data ) ; }
Parses the view using the Blade Factory .
49,978
protected function echoPageLeader ( ) : void { echo '<!DOCTYPE html>' ; echo Html :: generateTag ( 'html' , [ 'xmlns' => 'http://www.w3.org/1999/xhtml' , 'xml:lang' => Abc :: $ babel -> getCode ( ) , 'lang' => Abc :: $ babel -> getCode ( ) ] ) ; echo '<head>' ; Abc :: $ assets -> echoMetaTags ( ) ; Abc :: $ assets -> e...
Echos the XHTML document leader i . e . the start html tag the head element and start body tag .
49,979
protected function assignFields ( $ fields ) { foreach ( $ fields as $ field ) { if ( ! $ field instanceof FieldInterface ) { throw new ModelException ( sprintf ( 'Field must be an instance of FieldInterface, got "%s"' , $ this -> getType ( $ field ) ) ) ; } $ field -> table ( $ this -> table ) ; $ this -> fields [ $ f...
Assigns fields to model
49,980
protected function assignIndexes ( $ indexes ) { foreach ( $ indexes as $ index ) { if ( ! $ index instanceof IndexInterface ) { throw new ModelException ( sprintf ( 'Index must be an instance of IndexInterface, got "%s"' , $ this -> getType ( $ index ) ) ) ; } foreach ( $ index -> fields ( ) as $ key => $ field ) { $ ...
Assigns indexes to model
49,981
protected function assignRelations ( $ relations ) { foreach ( $ relations as $ relation ) { if ( ! $ relation instanceof RelationInterface ) { throw new ModelException ( sprintf ( 'Relation must be an instance of RelationInterface, got "%s"' , $ this -> getType ( $ relation ) ) ) ; } foreach ( array_keys ( $ relation ...
Assigns relations to model
49,982
protected function assertField ( $ field ) { if ( ! $ this -> hasField ( $ field ) ) { throw new ModelException ( sprintf ( 'Unknown field, field "%s" not found in model "%s"' , $ field , $ this -> entity ) ) ; } }
Asserts if model has field
49,983
public function primaryFields ( ) { $ result = [ ] ; foreach ( $ this -> indexes as $ index ) { if ( ! $ index -> isPrimary ( ) ) { continue ; } foreach ( $ index -> fields ( ) as $ field ) { $ result [ ] = $ this -> field ( $ field ) ; } } return $ result ; }
Returns array containing names of primary indexes
49,984
public function indexFields ( ) { $ fields = [ ] ; foreach ( $ this -> indexes as $ index ) { $ fields = array_merge ( $ fields , $ index -> fields ( ) ) ; } $ result = [ ] ; foreach ( array_unique ( $ fields ) as $ field ) { $ result [ ] = $ this -> field ( $ field ) ; } return $ result ; }
Returns array of fields from indexes
49,985
public function index ( $ index ) { if ( empty ( $ this -> indexes [ $ index ] ) ) { throw new ModelException ( sprintf ( 'Unknown index, index "%s" not found in model "%s"' , $ index , $ this -> entity ) ) ; } return $ this -> indexes [ $ index ] ; }
Returns index definition
49,986
public function referredIn ( $ field ) { $ result = [ ] ; foreach ( $ this -> relations as $ relation ) { if ( false === $ i = array_search ( $ field , $ relation -> localKeys ( ) ) ) { continue ; } $ result [ $ relation -> foreignKeys ( ) [ $ i ] ] = $ relation ; } return $ result ; }
Returns all relation where field is listed as local key
49,987
public function relation ( $ relationName ) { if ( ! $ relation = $ this -> findRelationByName ( $ relationName ) ) { throw new ModelException ( sprintf ( 'Unknown relation, relation "%s" not found in model "%s"' , $ relationName , $ this -> entity ) ) ; } return $ relation ; }
Returns relation definition for passed entity class
49,988
protected function findRelationByName ( $ relationName ) { foreach ( $ this -> relations as $ relation ) { if ( $ relation -> name ( ) == $ relationName || $ relation -> entity ( ) == $ relationName ) { return $ relation ; } } return null ; }
Finds relation by its name
49,989
public function remove ( ) { $ removed = 0 ; foreach ( func_get_args ( ) as $ arg ) { if ( $ arg instanceof Container ) { $ originalCount = $ this -> count ( ) ; $ this -> collection = array_diff_key ( $ this -> collection , $ arg -> collection ) ; $ removed += ( $ originalCount - $ this -> count ( ) ) ; } else { $ sea...
Remove entities from collection
49,990
public function mapCombine ( $ keys , $ values ) { return array_combine ( array_map ( $ keys , $ this -> collection ) , array_map ( $ values , $ this -> collection ) ) ; }
MapCombine . Like array map but takes a callback for the array keys
49,991
public function pluck ( $ property , $ ifEmptyDefaultToContainer = false ) { $ mapper = $ this -> getPropertyMapper ( $ property ) ; $ isAllObjects = true ; $ output = [ ] ; foreach ( $ this -> collection as $ obj ) { $ propertyValue = $ mapper -> get ( $ obj ) ; $ isAllObjects = $ isAllObjects and is_object ( $ proper...
Pluck a property from the collection
49,992
private function generateSortByPropertyClosure ( $ property , $ direction = SORT_ASC ) { if ( $ direction === SORT_DESC ) { $ aLTb = 1 ; $ aGTb = - 1 ; } else { $ aLTb = - 1 ; $ aGTb = 1 ; } $ mapper = $ this -> getPropertyMapper ( $ property ) ; return function ( $ a , $ b ) use ( $ mapper , $ aLTb , $ aGTb ) { $ prop...
Return a user defined sort comparison function that is property mapper aware .
49,993
private function generateGetPropertyClosure ( $ property ) { $ mapper = $ this -> getPropertyMapper ( $ property ) ; return function ( $ obj ) use ( $ mapper ) { return $ mapper -> get ( $ obj ) ; } ; }
Returns a callable to access a object property
49,994
public function sortByProperty ( $ property , $ direction = null ) { $ this -> sort ( $ this -> generateSortByPropertyClosure ( $ property , $ direction ) ) ; return $ this ; }
Sort container by property
49,995
private function checkEntity ( $ obj ) { if ( $ class = $ this -> classGet ( ) and ! ( $ obj instanceof $ class ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Obj %s is not compatible with Container of class %s' , get_class ( $ obj ) , $ class ) ) ; } return true ; }
Check an entity implments ContainerInterface . It should be the same type of entities already in collection .
49,996
private function checkEntityArray ( array $ entityArray , & $ error = null ) { if ( $ existing = $ this -> classGet ( ) ) { foreach ( $ entityArray as $ value ) { if ( ! ( $ value instanceof $ existing ) ) { $ error = "Can't add entity of class `" . get_class ( $ value ) . "` to container of class `{$existing}`." ; ret...
Check if a array of Entity s is compatible with this container
49,997
public function contains ( ) { $ output = true ; $ args = func_get_args ( ) ; while ( list ( , $ value ) = each ( $ args ) and $ output ) { if ( $ value instanceof Container ) { $ numChecking = count ( $ value ) ; $ numContained = count ( array_intersect_key ( $ value -> collection , $ this -> collection ) ) ; $ testRe...
Does this container contain the following entities
49,998
private function arrayHelperMethod ( $ fn , array $ args ) { $ class = $ this -> classGet ( ) ; $ fnArguments = array ( $ this -> collection ) ; foreach ( $ args as $ container ) { if ( ! ( $ container instanceof $ this ) ) { throw new \ InvalidArgumentException ( "You can only `{$fn}` containers." ) ; } $ containerCla...
Validation and execution helper method for intersect and diff .
49,999
public function randomGet ( $ n = null , $ returnContainer = false , $ removeFromContainer = false ) { $ n = $ n === null ? 1 : ( int ) $ n ; if ( 0 === $ containerSize = $ this -> count ( ) ) { if ( $ returnContainer or $ n > 1 ) { return $ this -> newContainer ( ) ; } return null ; } if ( $ n === 1 ) { $ key = array_...
Return a random number of entities from this collection . If n = 1 you will recieve a entity otherwise you will get a container