idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
54,800
public function warn ( $ message , array $ context = array ( ) ) { return $ this -> _instance -> addRecord ( \ Monolog \ Logger :: WARNING , $ message , $ context ) ; }
Adds a log record at the WARNING level .
54,801
public function err ( $ message , array $ context = array ( ) ) { return $ this -> _instance -> addRecord ( \ Monolog \ Logger :: ERROR , $ message , $ context ) ; }
Adds a log record at the ERROR level .
54,802
public function emergency ( $ message , array $ context = array ( ) ) { return $ this -> _instance -> addRecord ( \ Monolog \ Logger :: EMERGENCY , $ message , $ context ) ; }
Adds a log record at the EMERGENCY level .
54,803
protected function addPointToUser ( $ number , $ beforePoint , $ afterPoint ) { if ( $ this -> pointNotIsset ( ) ) $ point = $ this -> createPointToUser ( ) ; else $ point = Point :: where ( 'user_id' , $ this -> id ) -> where ( 'rule_id' , $ this -> ruleId ) -> first ( ) ; $ this -> logPoint ( $ point -> id , $ number...
update user point
54,804
private function createPointToUser ( $ number = null ) { return Point :: create ( [ 'user_id' => $ this -> id , 'rule_id' => $ this -> ruleId , 'number' => $ number ] ) ; }
create point to user
54,805
public static function command ( string $ command , bool $ passThrough = false ) : CommandResultInterface { return new CommandResult ( new static ( $ command , $ passThrough ) ) ; }
Creates new instance of self and passes it to new instance of CommandResult
54,806
public function convertFrom ( $ source , $ targetType , array $ convertedChildProperties = [ ] , PropertyMappingConfigurationInterface $ configuration = null ) { $ result = [ ] ; $ array = ( 'array' === $ targetType ) ? $ source : $ convertedChildProperties ; foreach ( $ array as $ name => $ subProperty ) { $ result [ ...
Converts into an array leaving child properties types .
54,807
public function showAction ( $ id , $ extra ) { $ entity = $ this -> container -> get ( "layout.read_handler" ) -> get ( $ id ) ; $ delete_form = $ this -> container -> get ( "layout.form_handler" ) -> createDeleteForm ( $ id ) ; $ layout = str_replace ( ":show.html.twig" , ":display.html.twig" , $ this -> container ->...
Finds and displays a layout entity .
54,808
public static function render ( $ m , $ rowLength = 16 , $ fillChar = ' ' , $ showOffset = true ) { $ res = '' ; $ rowOffset = 0 ; $ bytes = '' ; $ hex = '' ; $ j = 0 ; for ( $ i = 0 ; $ i < strlen ( $ m ) ; $ i ++ ) { $ x = substr ( $ m , $ i , 1 ) ; $ bytes .= self :: decodeReadable ( $ x ) ; $ hex .= bin2hex ( $ x )...
Prints hex dump of a binary string similar to xxd
54,809
protected function setFooterCommon ( $ footerInjected = null ) { $ sHK = $ this -> tCmnSuperGlobals -> get ( 'specialHook' ) ; if ( ! is_null ( $ sHK ) && ( in_array ( 'noHeader' , $ sHK ) ) ) { return '' ; } return $ this -> setFooterCommonInjected ( $ footerInjected ) . '</body></html>' ; }
Outputs an HTML footer
54,810
protected function setHeaderCommon ( $ headerFeatures = [ ] ) { $ sReturn = [ ] ; $ this -> initializeSprGlbAndSession ( ) ; $ sHK = $ this -> tCmnSuperGlobals -> get ( 'specialHook' ) ; if ( ! is_null ( $ sHK ) && ( in_array ( 'noHeader' , $ sHK ) ) ) { return '' ; } $ fixedHeaderElements = [ 'start' => '<!DOCTYPE htm...
Outputs an HTML header
54,811
public function scan ( $ filepath ) { $ proc = new Process ( sprintf ( '%s %s --Output=XML --Full' , $ this -> path , $ filepath ) ) ; $ proc -> run ( ) ; if ( ! $ proc -> isSuccessful ( ) ) { throw new \ RuntimeException ( $ proc -> getErrorOutput ( ) ) ; } $ result = $ proc -> getOutput ( ) ; $ xml = simplexml_load_s...
Scans a file to return any structured metadata .
54,812
public static function fullUrl ( ) { $ s = empty ( $ _SERVER [ "HTTPS" ] ) ? '' : ( $ _SERVER [ "HTTPS" ] == "on" ) ? "s" : "" ; $ protocol = StringUtils :: strLeft ( strtolower ( $ _SERVER [ "SERVER_PROTOCOL" ] ) , "/" ) . $ s ; $ port = ( $ _SERVER [ "SERVER_PORT" ] == "80" || $ _SERVER [ "SERVER_PORT" ] == "443" ) ?...
Returns the current full url
54,813
public static function safeUrl ( $ url ) { if ( empty ( $ url ) ) return '' ; if ( ! preg_match ( "/^(https?):\/\//" , $ url ) ) $ url = 'http://' . $ url ; if ( ! self :: isURL ( $ url ) ) $ url = '' ; return filter_var ( $ url , FILTER_SANITIZE_URL ) ; }
Outputs a safe url stripped of xss autolink on domain and stripped of invalid chars
54,814
public static function resolveContextVariables ( $ value , $ object ) { $ value = str_replace ( array ( '%PATH_BUILD%' , '%CONTEXT%' , '%REWRITE_BASE%' , '%SERVER_NAME%' , '%DEVICE_VIEW%' , '%DESIGN%' , '%DOMAIN%' , '%DOMAIN_BASE_URI%' , '%DEPLOYMENT_BASE_PATH%' ) , array ( PATH_BUILD , ( $ object instanceof ContextObj...
Replace variables inside a value using the object as an originating reference
54,815
public static function resolveSiteFromArray ( $ siteArray , $ useDomainAlias = false ) { $ site = new Site ( ) ; return self :: resolveSiteContextObject ( $ site , $ siteArray , $ useDomainAlias ) ; }
Creates a Site object from an array originating from the environments . xml
54,816
public static function resolveContextFromArray ( $ contextArray , $ useDomainAlias = false ) { $ context = new ContextObject ( ) ; return self :: resolveSiteContextObject ( $ context , $ contextArray , $ useDomainAlias ) ; }
Creates a ContextObject object from an array originating from the environments . xml
54,817
public function create ( $ request , $ match , $ p ) { if ( isset ( $ match [ 'collectionId' ] ) ) { $ collectionId = $ match [ 'collectionId' ] ; $ request -> REQUEST [ 'collection' ] = $ collectionId ; } else { $ collectionId = $ request -> REQUEST [ 'collection' ] ; } Pluf_Shortcuts_GetObjectOr404 ( 'Collection_Coll...
Creates new instance of a document
54,818
public function get ( $ request , $ match ) { if ( isset ( $ match [ 'collectionId' ] ) ) { $ collectionId = $ match [ 'collectionId' ] ; } else { $ collectionId = $ request -> REQUEST [ 'collectionId' ] ; } $ collection = Pluf_Shortcuts_GetObjectOr404 ( 'Collection_Collection' , $ collectionId ) ; $ document = Pluf_Sh...
Gets a document
54,819
public function find ( $ request , $ match ) { if ( isset ( $ match [ 'collectionId' ] ) ) { $ collectionId = $ match [ 'collectionId' ] ; } elseif ( isset ( $ request -> REQUEST [ 'collectionId' ] ) ) { $ collectionId = $ request -> REQUEST [ 'collectionId' ] ; } $ document = new Collection_Document ( ) ; $ paginator ...
Search for an document
54,820
public function remove ( $ request , $ match ) { if ( isset ( $ match [ 'collectionId' ] ) ) { $ collectionId = $ match [ 'collectionId' ] ; } else { $ collectionId = $ request -> REQUEST [ 'collectionId' ] ; } $ collection = Pluf_Shortcuts_GetObjectOr404 ( 'Collection_Collection' , $ collectionId ) ; if ( isset ( $ ma...
Removes a document
54,821
public function update ( $ request , $ match , $ p ) { if ( isset ( $ match [ 'collectionId' ] ) ) { $ collectionId = $ match [ 'collectionId' ] ; $ request -> REQUEST [ 'collection' ] = $ collectionId ; } else { $ collectionId = $ request -> REQUEST [ 'collection' ] ; } $ collection = Pluf_Shortcuts_GetObjectOr404 ( '...
Updates a document
54,822
public function putMap ( $ request , $ match ) { if ( isset ( $ match [ 'collectionId' ] ) ) { $ collectionId = $ match [ 'collectionId' ] ; } else { $ collectionId = $ request -> REQUEST [ 'collectionId' ] ; } if ( isset ( $ match [ 'documentId' ] ) ) { $ documentId = $ match [ 'documentId' ] ; } else { $ documentId =...
Puts attributes of a document
54,823
private function connect ( ) { $ this -> sessionLink = mysqli_connect ( $ this -> host_master , $ this -> user , $ this -> password , $ this -> name ) or die ( "Error " . mysqli_error ( $ this -> sessionLink ) ) ; }
NOT WORKING!!! Lazy - connects to the database .
54,824
public function getKeyedByPropertyMulti ( $ property ) { $ keyed = [ ] ; foreach ( $ this as $ model ) { if ( empty ( $ keyed [ $ model -> $ property ] ) ) { $ keyed [ $ model -> $ property ] = [ ] ; } $ keyed [ $ model -> $ property ] [ ] = $ model ; } return $ keyed ; }
key the iterator by the specified property but go 2 levels
54,825
public function loadFromArray ( array $ data , $ useKeys = true ) { $ this -> items = array ( ) ; foreach ( $ data as $ key => $ item ) { $ this -> items [ ] = $ item ; } }
Loads collection values from the given array
54,826
public static function getDefinitionFormContainer ( CompilerExtension $ compilerExtension , $ indexConfig = 'formContainer' , $ prefixName = 'formContainer' ) : ServiceDefinition { $ builder = $ compilerExtension -> getContainerBuilder ( ) ; $ config = $ compilerExtension -> getConfig ( ) ; return $ builder -> addDefin...
Get definition form container .
54,827
public static function getDefinitionEventContainer ( CompilerExtension $ compilerExtension , $ indexConfig = 'events' ) : array { $ builder = $ compilerExtension -> getContainerBuilder ( ) ; $ config = $ compilerExtension -> getConfig ( ) ; $ events = [ ] ; foreach ( $ config [ $ indexConfig ] as $ index => $ event ) {...
Get definition event container .
54,828
public function chainSaving ( array & $ tasks , $ key ) { if ( $ this -> isNew ( ) or $ this -> isChanged ( ) ) { $ tasks [ $ key ] = $ this ; } }
Add a object to the chain task array if it is changed or new Required for ChainSavingInterface
54,829
public function md5 ( ) { if ( isset ( $ this -> filePath ) ) { return md5_file ( $ this -> filePath ) ; } elseif ( $ this -> oid ) { $ query = new Query ( "SELECT common.md5( %oid:oid|cast% );" , array ( 'oid' => $ this -> oid ) ) ; return $ this -> oid -> pg -> query ( $ query ) -> fetch ( Result :: FETCH_SINGLE ) ; ...
Return the MD5 hash of the data
54,830
public function data ( ) { if ( isset ( $ this -> filePath ) ) { return file_get_contents ( $ this -> filePath ) ; } elseif ( $ this -> oid ) { $ pg = $ this -> oid -> pg ; $ pg -> query ( new Query ( 'BEGIN' ) ) ; $ handle = pg_lo_open ( $ pg -> resource -> get ( ) , $ this -> oid -> oid , 'r' ) ; $ result = '' ; whil...
Get the data stored in the large object resource .
54,831
public function export ( $ destination , $ overwriteIfExists = false ) { if ( ! is_string ( $ destination ) ) { throw new \ RuntimeException ( sprintf ( 'Expected $destination to be a string, got type: %s' , gettype ( $ destination ) ) ) ; } if ( file_exists ( $ destination ) and ! $ overwriteIfExists ) { throw new \ R...
Export the data stored in the large object resource to the specified file .
54,832
public function stream ( ) { if ( isset ( $ this -> filePath ) ) { return readfile ( $ this -> filePath ) ; } elseif ( $ this -> oid ) { $ pg = $ this -> oid -> pg ; $ pg -> query ( new Query ( 'BEGIN' ) ) ; $ handle = pg_lo_open ( $ pg -> resource -> get ( ) , $ this -> oid -> oid , 'r' ) ; pg_lo_read_all ( $ handle )...
Output the data stored in the large object resource to stdout .
54,833
public function run ( ) { if ( ! isset ( $ this -> configs [ 'instances' ] ) || ! Any :: isArray ( $ this -> configs [ 'instances' ] ) ) { return null ; } $ time = time ( ) ; $ log = [ ] ; foreach ( $ this -> configs [ 'instances' ] as $ callback => $ delay ) { if ( ( ( int ) $ this -> configs [ 'log' ] [ $ callback ] ...
Run cron task . Attention - this method is too fat to run from any app s
54,834
public function remove ( $ class , $ method ) { $ callback = $ class . '::' . $ method ; if ( isset ( $ this -> configs [ 'instances' ] [ $ callback ] ) ) { unset ( $ this -> configs [ 'instances' ] [ $ callback ] , $ this -> configs [ 'log' ] [ $ callback ] ) ; App :: $ Properties -> writeConfig ( 'Cron' , $ this -> c...
Remove registered cron task from configs
54,835
public function create ( $ classToMock ) { $ mockBuilder = new \ PHPUnit_Framework_MockObject_MockBuilder ( $ this -> testCase , $ classToMock ) ; $ mockBuilder -> disableOriginalConstructor ( ) ; return $ mockBuilder -> getMock ( ) ; }
Creates simple PHPUnit Mock Object with disabled original constructor
54,836
private function _parse_routes ( ) { $ uri = implode ( '/' , $ this -> uri -> segments ( ) ) ; if ( isset ( $ this -> router [ $ uri ] ) ) { return $ this -> _set_request ( explode ( '/' , $ this -> router [ $ uri ] ) ) ; } foreach ( $ this -> router as $ key => $ val ) { $ key = str_replace ( ':any' , '.+' , str_repla...
disini mo ba atur akan apa mo kamana
54,837
private function registerLaravelSeoPackage ( ) { $ this -> registerProvider ( LaravelSeoServiceProvider :: class ) ; $ this -> app -> booting ( function ( ) { Seo :: setConfig ( 'database' , config ( 'arcanesoft.seo.database' ) ) ; Seo :: setConfig ( 'metas' , config ( 'arcanesoft.seo.metas' ) ) ; Seo :: setConfig ( 'r...
Register Laravel Seo package .
54,838
public function verifyWebhookSignature ( ) { $ timestamp = $ this -> request -> input ( 'timestamp' ) ; $ token = $ this -> request -> input ( 'token' ) ; $ signature = $ this -> request -> input ( 'signature' ) ; $ configMailgun = config ( 'services.mailgun' ) ; $ hmac = hash_hmac ( 'sha256' , $ timestamp . $ token , ...
Ensure the authenticity of inbound Mailgun request
54,839
public function isInboundEmailToEmailAddressMapToUser ( ) { $ mappedRoutes = config ( 'lasallecmsmailgun.inbound_map_mailgun_routes_with_user_email_address' ) ; foreach ( $ mappedRoutes as $ route => $ user ) { if ( $ this -> request -> input ( 'recipient' ) == $ route ) { return true ; } } return false ; }
Does the recipient s email address map to an email address in the users database table?
54,840
public function isMappedUserExistInUsersTable ( ) { $ mappedRoutes = config ( 'lasallecmsmailgun.inbound_map_mailgun_routes_with_user_email_address' ) ; foreach ( $ mappedRoutes as $ route => $ user ) { if ( $ this -> request -> input ( 'recipient' ) == $ route ) { $ userEmailAddress = $ user ; } } if ( $ this -> userR...
Does the mapped user actually exist in the users db table?
54,841
private static function staticTranslate ( $ source , $ target , $ string ) { self :: checkStaticInstance ( ) ; try { $ result = self :: $ staticInstance -> setSource ( $ source ) -> setTarget ( $ target ) -> translate ( $ string ) ; } catch ( Exception $ e ) { throw $ e ; } return $ result ; }
Translate text statically .
54,842
public function setLemma ( \ Innova \ LexiconBundle \ Entity \ Lemma $ lemma = null ) { $ this -> lemma = $ lemma ; return $ this ; }
Set lemma .
54,843
public function setNumber ( \ Innova \ LexiconBundle \ Entity \ Number $ number = null ) { $ this -> number = $ number ; return $ this ; }
Set number .
54,844
public function setGender ( \ Innova \ LexiconBundle \ Entity \ Gender $ gender = null ) { $ this -> gender = $ gender ; return $ this ; }
Set gender .
54,845
public function setTense ( \ Innova \ LexiconBundle \ Entity \ Tense $ tense = null ) { $ this -> tense = $ tense ; return $ this ; }
Set tense .
54,846
public function setPerson ( \ Innova \ LexiconBundle \ Entity \ Person $ person = null ) { $ this -> person = $ person ; return $ this ; }
Set person .
54,847
public function setMood ( \ Innova \ LexiconBundle \ Entity \ Mood $ mood = null ) { $ this -> mood = $ mood ; return $ this ; }
Set mood .
54,848
public static function decode ( $ string , $ returnArrays = false ) { $ result = json_decode ( $ string , $ returnArrays ) ; if ( function_exists ( 'json_last_error' ) ) { switch ( json_last_error ( ) ) { case JSON_ERROR_NONE : return $ result ; case JSON_ERROR_DEPTH : throw new JSONException ( 'json_decode - Maximum s...
Performs a JSON decode of the string
54,849
public static function encode ( $ obj , $ pretty = false , $ html = false ) { $ s = json_encode ( $ obj ) ; if ( $ pretty ) { return self :: format ( $ s , $ html ) ; } return $ s ; }
Encodes the object in json
54,850
public static function format ( $ json , $ html = false ) { $ format = str_replace ( [ ' ' , '\/' , ] , [ ' ' , '/' , ] , json_encode ( json_decode ( str_replace ( [ "\n" , ' ' , ', }' , ', ]' , ',}' , ',]' , ] , [ '' , '' , '}' , '}' , '}' , ']' , ] , $ json ) ) , JSON_PRETTY_PRINT ) ) ; if ( $ html ) { return st...
Indents a flat JSON string to make it more human - readable Use php function JSON_PRETTY_PRINT . Require php > = 5 . 4
54,851
public function isRequestedUrlClean ( Request \ Web $ request ) { $ server = $ request -> getServer ( ) ; if ( ! isset ( $ server [ 'REQUEST_URI' ] ) ) { throw new Exception ( 'REQUEST_URI is not set' ) ; } return strpos ( $ server [ 'REQUEST_URI' ] , $ this -> entryPoint ) !== 0 ; }
Check that requested URL is clean
54,852
protected function validateRouteMapping ( Route \ Mapping $ mapping ) { if ( ! class_exists ( $ mapping -> controller ( ) ) ) { throw new Exception ( "Controller '{$mapping->controller()}' not found" ) ; } if ( ! method_exists ( $ mapping -> controller ( ) , $ mapping -> action ( ) ) ) { throw new Exception ( "Action '...
Validate Route Mapping
54,853
public function TimezoneToInterval ( ) { $ timezone = $ this -> Value -> getTimezone ( ) -> getName ( ) ; if ( $ timezone == "Z" || $ timezone == "+00:00" || $ timezone == date_default_timezone_get ( ) ) { return DayTimeDurationValue :: Parse ( "PT0S" ) ; } if ( ! preg_match ( "/(?<sign>[+-])(?<hours>\d{2,2}):(?<minute...
Create a DayTimeDurationValue representation of the timezone offset
54,854
public function actionLogin ( ) { if ( ! \ Yii :: $ app -> user -> isGuest ) { \ Yii :: $ app -> getResponse ( ) -> redirect ( Url :: to ( [ \ Yii :: $ app -> getHomeUrl ( ) ] ) ) ; } $ model = \ Yii :: createObject ( LoginForm :: className ( ) ) ; $ event = $ this -> getFormEvent ( $ model ) ; $ this -> performAjaxVal...
Displays the login page .
54,855
public function actionLogout ( ) { $ event = $ this -> getUserEvent ( \ Yii :: $ app -> user -> identity ) ; $ this -> trigger ( self :: EVENT_BEFORE_LOGOUT , $ event ) ; \ Yii :: $ app -> getUser ( ) -> logout ( ) ; $ this -> trigger ( self :: EVENT_AFTER_LOGOUT , $ event ) ; \ Yii :: $ app -> getResponse ( ) -> redir...
Logs the user out and then redirects to the homepage .
54,856
protected function askToSkip ( ) { $ question = 'This part is optional. Do you like to configure it? [y|N]:' ; $ answer = strtolower ( IO :: in ( $ question ) ) ; switch ( $ answer ) { case 'yes' : case 'y' : case '1' : case 'true' : return false ; case 'no' : case 'n' : case '0' : case 'false' : case '' : return true ...
Ask to skip optional part
54,857
protected function askForString ( $ key , $ required = false , $ default = null , array $ values = [ ] , $ minLength = 0 ) { $ question = sprintf ( 'What is the value for configuration setting "%s"' , $ key ) ; if ( count ( $ values ) > 0 ) { $ question .= sprintf ( ' (%s)' , implode ( ', ' , $ values ) ) ; } $ questio...
Ask user for a value which should be a string
54,858
protected function askForBoolean ( $ key , $ required = false , $ default = null ) { $ question = sprintf ( 'Enable configuration setting "%s"?' , $ key ) ; if ( isset ( $ default ) ) { switch ( $ default ) { case true : $ question .= ' [Y|n]:' ; break ; case false : $ question .= ' [y|N]:' ; break ; } } $ answer = str...
Ask user for a value which should be a boolean
54,859
protected function askForMixed ( $ key , $ required = false , $ default = null , array $ values = [ ] ) { $ question = sprintf ( 'What is the value for configuration setting "%s"' , $ key ) ; $ options = [ ] ; if ( count ( $ values ) > 0 ) { foreach ( $ values as $ value ) { switch ( gettype ( $ value ) ) { case 'boole...
Ask user for a value but the data type doesn t matter
54,860
protected function containsRecursive ( & $ array , & $ value ) { if ( ! is_array ( $ array ) ) { return false ; } foreach ( $ array as $ sub ) { if ( is_string ( $ sub ) && ! strcasecmp ( $ sub , $ value ) ) { return true ; } if ( is_array ( $ sub ) && $ this -> containsRecursive ( $ sub , $ value ) ) { return true ; }...
Checks whether some array contains the given data in a recursive fashion .
54,861
public function registerTriggers ( $ triggers , $ channel ) { if ( ! is_array ( $ triggers ) ) { $ triggers = array ( $ triggers ) ; } $ fmt = $ this -> getFormatter ( false ) ; $ translator = $ fmt -> getTranslator ( ) ; if ( ! is_string ( $ channel ) ) { throw new \ Erebot \ InvalidValueException ( $ fmt -> _ ( 'Inva...
Registers a series of triggers either globally or for a specific channel .
54,862
public function getChanTriggers ( $ channel ) { if ( ! isset ( $ this -> triggers [ $ channel ] ) ) { $ fmt = $ this -> getFormatter ( false ) ; throw new \ Erebot \ NotFoundException ( $ fmt -> _ ( 'No triggers found for channel "<var name="chan"/>"' , array ( 'chan' => $ channel ) ) ) ; } return $ this -> triggers [ ...
Returns a list of all triggers registered for a given channel .
54,863
public function getTriggers ( $ token ) { $ fmt = $ this -> getFormatter ( false ) ; if ( ! is_string ( $ token ) || strpos ( $ token , ' ' ) === false ) { throw new \ Erebot \ InvalidValueException ( $ fmt -> _ ( 'Invalid token' ) ) ; } list ( $ chan , $ pos ) = explode ( ' ' , $ token ) ; if ( ! isset ( $ this -> tri...
Returns a list of all triggers associated with the given key .
54,864
public function my ( ) { $ profile = $ this -> Profiles -> find ( ) -> where ( [ 'Profiles.user_id' => $ this -> Auth -> user ( 'id' ) ] ) -> contain ( 'Users' ) -> first ( ) ; $ this -> set ( 'profile' , $ profile ) ; $ this -> set ( '_serialize' , [ 'profile' ] ) ; }
Shows current user profile
54,865
public function tearDown ( ) { $ seconds = time ( ) - $ this -> start ; switch ( $ seconds ) { case 1 : $ this -> log -> debug ( 'This took 1 second.' ) ; break ; default : $ this -> log -> debug ( 'This took %s seconds.' , $ seconds ) ; break ; } $ prettifyUnit = function ( $ bytes ) { $ unit = [ 'B' , 'KiB' , 'MiB' ,...
Process some routines after executing command
54,866
protected function getQuery ( ) { $ query = '' ; foreach ( $ this -> config [ 'args' ] as $ index => $ arg ) { if ( array_key_exists ( 'command' , $ this -> config ) && $ arg === $ this -> config [ 'command' ] && array_key_exists ( ( $ index + 1 ) , $ this -> config [ 'args' ] ) ) { $ query = $ this -> config [ 'args' ...
Looks for a query from given arguments
54,867
public function getName ( ) { foreach ( $ this -> config [ 'commands' ] as $ command => $ details ) { if ( strpos ( $ details [ 'class' ] , get_class ( $ this ) ) !== false ) { return $ command ; } } return '' ; }
Get command name
54,868
protected function _get ( \ Throwable $ e ) { $ path_to_root = $ _SERVER [ 'DOCUMENT_ROOT' ] ; $ rows = array ( ) ; $ rows [ ] = [ str_replace ( $ path_to_root . '/' , '' , $ e -> getFile ( ) ) , $ e -> getLine ( ) , "throw new " . get_class ( $ e ) , "" ] ; foreach ( $ e -> getTrace ( ) as $ trace ) { $ rows [ ] = [ s...
Get a 2 - dimensions array with exception stack trace
54,869
public function translateByNumber ( int $ number , string $ defaultTranslation , ... $ args ) : string { $ transStr = $ this -> _source -> getTranslation ( $ number , $ defaultTranslation ) ; if ( \ count ( $ args ) < 1 ) { return $ transStr ; } return \ sprintf ( $ transStr , $ args ) ; }
Gets the translation by an numeric identifier .
54,870
protected function runMigrationByPaths ( $ migrationPaths , $ command ) { $ app = $ this -> mockApplication ( ) ; $ this -> validateMigrationPaths ( $ migrationPaths ) ; foreach ( $ migrationPaths as $ migrationPath ) { $ migrateController = $ this -> buildMigration ( $ app ) ; $ migrateController -> migrationPath = $ ...
Run migration by paths
54,871
protected function validateMigrationPaths ( $ migrationPaths ) { foreach ( $ migrationPaths as $ migrationPath ) { $ path = \ Yii :: getAlias ( $ migrationPath , false ) ; if ( $ path === false ) { throw new ExtensionException ( __CLASS__ , "Invalid path alias: $migrationPath" ) ; } if ( ! file_exists ( $ path ) ) { th...
Validate Migration Path
54,872
protected function runMigrationByNamespaces ( $ migrationNamespaces , $ command ) { $ app = $ this -> mockApplication ( ) ; $ migrateController = $ this -> buildMigration ( $ app ) ; $ migrateController -> migrationNamespaces = $ migrationNamespaces ; $ this -> runMigration ( $ migrateController , $ command ) ; $ this ...
Run migration by namespaces
54,873
protected function runMigrationByApplication ( $ command ) { $ app = $ this -> mockApplication ( ) ; list ( $ migrateController , $ route ) = $ app -> createController ( 'migrate' ) ; if ( $ migrateController === null ) { throw new ExtensionException ( __CLASS__ , "At least one of `migrationPath` or `migrationNamespace...
Run migration from app config
54,874
protected function mockApplication ( ) { $ entryUrl = $ this -> config [ 'entryUrl' ] ; $ entryFile = $ this -> config [ 'entryScript' ] ? : basename ( $ entryUrl ) ; $ entryScript = $ this -> config [ 'entryScript' ] ? : parse_url ( $ entryUrl , PHP_URL_PATH ) ; $ this -> client = new Yii2Connector ( ) ; $ this -> cli...
Mocks up the application instance .
54,875
private function AddEMailField ( ) { $ name = 'EMail' ; $ this -> AddField ( Input :: Text ( $ name , $ this -> member -> GetEMail ( ) ) ) ; $ this -> SetRequired ( $ name ) ; $ this -> AddValidator ( $ name , PhpFilter :: EMail ( ) ) ; $ this -> AddValidator ( $ name , DatabaseCount :: UniqueField ( $ this -> member ,...
Adds the email field to the form
54,876
private function AddPasswordField ( ) { $ name = 'Password' ; $ this -> AddField ( Input :: Password ( $ name ) ) ; if ( ! $ this -> member -> Exists ( ) ) { $ this -> SetRequired ( $ name ) ; } $ this -> AddValidator ( $ name , StringLength :: MinLength ( 6 ) ) ; $ this -> SetTransAttribute ( $ name , 'placeholder' ) ...
Adds the password field to the form
54,877
protected function OnSuccess ( ) { $ action = $ this -> member -> Exists ( ) ? Action :: Update ( ) : Action :: Create ( ) ; $ this -> member -> SetName ( $ this -> Value ( 'Name' ) ) ; $ this -> member -> SetEMail ( $ this -> Value ( 'EMail' ) ) ; $ this -> SetPassword ( ) ; $ this -> member -> Save ( ) ; $ logger = n...
Saves the user
54,878
private function DeleteOldGroups ( array $ selGroupIDs ) { $ tblMmg = MemberMembergroup :: Schema ( ) -> Table ( ) ; $ sql = Access :: SqlBuilder ( ) ; $ where = $ sql -> Equals ( $ tblMmg -> Field ( 'Member' ) , $ sql -> Value ( $ this -> member -> GetID ( ) ) ) ; if ( count ( $ selGroupIDs ) > 0 ) { $ selectedList = ...
Deletes the unselected group ids
54,879
private function SaveNewGroups ( array $ exGroupIDs , array $ selGroupIDs ) { foreach ( $ selGroupIDs as $ selGroupID ) { if ( ! in_array ( $ selGroupID , $ exGroupIDs ) ) { $ mmg = new MemberMembergroup ( ) ; $ mmg -> SetMember ( $ this -> member ) ; $ mmg -> SetMemberGroup ( new Membergroup ( $ selGroupID ) ) ; $ mmg...
Saves the new groups
54,880
public function setDefaultValue ( $ value = null ) { if ( ! $ this -> value ) { if ( $ value = $ value ? : config ( "fields.values.{$this->key}" ) ) { foreach ( ( array ) $ value as $ locale => $ translation ) { $ locale = is_string ( $ locale ) ? $ locale : $ this -> getDefaultLocale ( ) ; $ this -> setTranslation ( '...
Check if value is not set and set it .
54,881
public function setDefaultDescription ( $ description = null ) { if ( ! $ this -> description ) { $ description = $ description ? : config ( "fields.descriptions.{$this->key}" , ucfirst ( $ this -> key ) ) ; foreach ( ( array ) $ description as $ locale => $ translation ) { $ locale = is_string ( $ locale ) ? $ locale ...
Check if description is not set and set it .
54,882
public function addTranslated ( string $ locale ) { if ( $ this -> isDefaultLocale ( $ locale ) ) { $ this -> translated = [ $ locale ] ; } else { $ translated = $ this -> getTranslated ( ) ; $ translated [ ] = $ locale ; $ this -> translated = array_unique ( $ translated ) ; } }
Set translated locale .
54,883
public static function normalizeHeaderName ( $ name ) { return preg_replace_callback ( "'-[a-z]'" , function ( $ m ) { return strtoupper ( $ m [ 0 ] ) ; } , ucfirst ( strtolower ( trim ( $ name ) ) ) ) ; }
Normalize an HTTP header name by capitalizing the first letter and all letters preceeded by a dash .
54,884
protected static function useStatic ( ) { if ( isset ( self :: $ _useStatic ) ) { return self :: $ _useStatic ; } self :: $ _useStatic = AssetsSettings :: assetsUseStatic ( ) ; return self :: $ _useStatic ; }
Get useStatic setting - use static resources
54,885
final public function setView ( View $ view ) { $ this -> view = $ view ; if ( ! $ this -> initializedView ) { $ this -> initializedView = true ; $ this -> init ( ) ; } return $ this ; }
Sets the view instance to use
54,886
final protected function resetUserIdentity ( AUser $ user = null , $ duration = null ) { engine ( 'resetUserIdentity' , $ user , $ duration ) ; return $ this ; }
Resets the user identity to guest
54,887
final protected function prepareInject ( ) { $ service = $ this -> getModule ( ) . '\Services\\' . $ this -> getClassName ( ) . 'Service' ; if ( class_exists ( $ service ) ) { return array_merge ( parent :: prepareInject ( ) , $ this -> getConfigInject ( 'controllers' ) , array ( 'service' => array ( 'class' => $ servi...
Prepares the injection
54,888
final public function getActions ( ) { $ return = array ( ) ; foreach ( get_class_methods ( $ this ) as $ method ) { if ( substr ( $ method , strlen ( $ method ) - 6 ) === 'Action' ) $ return [ ] = substr ( $ method , 0 , strlen ( $ method ) - 6 ) ; } return $ return ; }
Fetches all actions in the controller
54,889
final protected function redirect ( $ module , $ controller = null , $ action = null , array $ params = array ( ) , $ hash = null ) { header ( 'Location: ' . $ this -> view -> url ( $ module , $ controller , $ action , $ params , $ hash ) ) ; exit ; }
Redirects to another resource
54,890
public static function isEmpty ( $ resource ) { if ( ! self :: isValid ( $ resource ) && null !== $ resource ) { return false ; } return String :: isEmpty ( $ resource ) ; }
Check if resource is empty
54,891
public static function isNotEmpty ( $ resource ) { if ( ! self :: isValid ( $ resource ) && null !== $ resource ) { return false ; } return ( $ resource !== null && $ resource !== '' ) ; }
Check if resource is note empty
54,892
private function getPagesSeeds ( ) { return [ [ 'name' => 'Pages - List all pages' , 'description' => 'Allow to list all pages.' , 'slug' => PagesPolicy :: PERMISSION_LIST , ] , [ 'name' => 'Pages - View a page' , 'description' => 'Allow to display a page.' , 'slug' => PagesPolicy :: PERMISSION_SHOW , ] , [ 'name' => '...
Get the Pages permissions .
54,893
private function getFootersSeeds ( ) { return [ [ 'name' => 'Footers - List all footers' , 'description' => 'Allow to list all footers.' , 'slug' => FootersPolicy :: PERMISSION_LIST , ] , [ 'name' => 'Footers - View a footer' , 'description' => 'Allow to display a footer.' , 'slug' => FootersPolicy :: PERMISSION_SHOW ,...
Get the Footers permissions .
54,894
private function getRedirectsSeeds ( ) { return [ [ 'name' => 'Redirects - List all redirections' , 'description' => 'Allow to list all redirections.' , 'slug' => RedirectsPolicy :: PERMISSION_LIST , ] , [ 'name' => 'Redirects - View a redirection' , 'description' => 'Allow to display a redirection.' , 'slug' => Redire...
Get the Redirects permissions .
54,895
public function render ( $ tpl , $ params = [ ] ) { $ this -> setTemplate ( $ tpl ) ; $ this -> params = ( object ) $ params ; return $ this -> retrieve ( ) ; }
Set the template name assign params array and return rendered output in one method . Call this function in routes and controllers .
54,896
public function setTemplate ( $ tpl , $ clearParams = true ) { if ( $ clearParams ) { $ this -> clearParams ( ) ; } $ this -> templateFile = $ this -> templatesPath . $ tpl . '.tpl.php' ; }
Set the name of the template to be used . Should not include file extension .
54,897
private function setTemplatesPath ( $ templatesPath ) { $ this -> templatesPath = $ templatesPath ; if ( ! is_readable ( $ this -> templatesPath ) ) { $ this -> error ( "Template Root Path ({$this->templatesPath}) does not exist or not readable." ) ; } }
Set the path to the templates directory .
54,898
private function protectedInclude ( ) { $ _tpl = $ this ; $ _view = function ( $ tplName , $ params = [ ] ) use ( $ _tpl ) { $ tplCopy = clone $ _tpl ; echo ( $ tplCopy -> render ( $ tplName , $ params ) ) ; unset ( $ tplCopy ) ; } ; $ _ss = function ( $ str ) { return htmlspecialchars ( $ str , ENT_QUOTES ) ; } ; $ al...
Wrap our template include into a method scope . This allows our template to have access only to the template params . It also prevents collisions with the global namespace .
54,899
protected function useCache ( ) { if ( $ this -> cache && $ this -> cacheExists ( ) ) { $ this -> templateOutput = $ this -> getCache ( ) ; if ( $ this -> templateOutput !== false ) { return true ; } } return false ; }
Determine if we can use a cached version of the template and if so fetch it .