idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
232,200
protected function normalizeAttributes ( ) { if ( $ this -> attributes === null ) { if ( $ this -> model instanceof Model ) { $ this -> attributes = $ this -> model -> attributes ( ) ; } elseif ( is_object ( $ this -> model ) ) { $ this -> attributes = $ this -> model instanceof Arrayable ? $ this -> model -> toArray (...
Normalizes the attribute specifications .
232,201
public function getUserBySlug ( $ slug ) { $ return = array ( ) ; $ users = $ this -> repository -> users ; foreach ( $ users as $ user ) { if ( $ user -> slug == $ slug ) { $ return = $ user ; break ; } } return $ return ; }
Get user by slug
232,202
public function deleteUserBySlug ( $ slug ) { $ userToDelete = $ this -> getUserBySlug ( $ slug ) ; if ( empty ( $ userToDelete ) ) { throw new \ Exception ( 'Trying to delete a user that doesn\'t exist.' ) ; } $ users = $ this -> getUsers ( ) ; foreach ( $ users as $ key => $ user ) { if ( $ user -> slug == $ userToDe...
Delete user by slug
232,203
private function buildPathFromSource ( string $ path ) : string { return str_replace ( '.' , '/' , str_replace ( $ this -> context . "." , '' , $ this -> viewNameFromSource ( $ path ) ) ) . $ this -> buildExtension ; }
start with the build path strip context from view name including first . replace remaining dots in view name with slashes add build extension
232,204
public function agent ( $ arg = null ) { $ agent = new Agent ( ) ; if ( $ arg ) { return $ agent -> is ( $ arg ) ; } return new Agent ( ) ; }
Start Jenssegers Agent
232,205
public function authRequest ( $ guard = null ) { return is_null ( $ guard ) ? request ( ) -> user ( ) ?? request ( ) -> user ( 'api' ) : request ( ) -> user ( $ guard ) ; }
Get auth request by guard
232,206
public function randomNumbers ( $ length = 6 ) { $ nums = '0123456789' ; $ out = $ nums [ mt_rand ( 1 , strlen ( $ nums ) - 1 ) ] ; for ( $ p = 0 ; $ p < $ length - 1 ; $ p ++ ) { $ out .= $ nums [ mt_rand ( 0 , strlen ( $ nums ) - 1 ) ] ; } return $ out ; }
Generate random numbers
232,207
public function fileSearch ( $ file , $ subject ) { return str_contains ( file_get_contents ( str_contains ( $ file , '/' ) ? $ file : $ file ) , $ subject ) ; }
Search for a content within a file
232,208
public function fileEdit ( $ file , $ search , $ replace ) { file_put_contents ( $ file , str_replace ( $ search , $ replace , file_get_contents ( $ file ) ) ) ; }
Edit part of the contents of a file
232,209
public function rangeHours ( $ start , $ end , $ interval = 1 , $ select = true ) { $ tStart = strtotime ( $ start ) ; $ tEnd = strtotime ( $ end ) ; $ tNow = $ tStart ; $ hours = [ ] ; while ( $ tNow <= $ tEnd ) { $ hours [ ] = date ( "H:i" , $ tNow ) ; $ tNow = strtotime ( '+' . $ interval . ' hour' , $ tNow ) ; } if...
Interval between two hours
232,210
public function limtitLines ( $ str , $ lines = 1 ) { $ line = "\n" ; for ( $ i = 2 ; $ i <= $ lines ; $ i ++ ) { $ line .= "\n" ; } return preg_replace ( "/[\r\n]+/" , "$line" , $ str ) ; }
Limits the amount of line breaks in a string
232,211
public function urlParser ( $ str , $ rule ) { $ linkify = new Linkify ( [ 'callback' => function ( $ url , $ caption , $ isEmail ) use ( $ rule ) { $ rule = str_replace ( '[url]' , $ url , $ rule ) ; $ rule = str_replace ( '[caption]' , $ caption , $ rule ) ; return $ rule ; } ] ) ; return $ linkify -> process ( $ str...
Parse URLs from string
232,212
public function urlParserMultiple ( $ str , $ rule , $ html = null ) { $ explode = explode ( ';' , $ str ) ; $ url = collect ( $ explode ) -> map ( function ( $ item ) use ( $ rule ) { return $ this -> urlParser ( $ item , $ rule ) ; } ) ; if ( is_null ( $ html ) ) { $ url = $ url -> all ( ) ; } else { $ url = $ url ->...
Parse multiple URLs from string separated by commas or semicolons
232,213
public function countries ( $ by = null , $ value = null ) { $ countries = json_decode ( file_get_contents ( __DIR__ . '/../../data/countries.json' ) , true ) ; if ( is_null ( $ by ) && is_null ( $ value ) ) { $ countries = collect ( $ countries ) -> values ( ) -> all ( ) ; } else { if ( $ by == 'locale' ) { $ value = ...
Countries search and list
232,214
public function countryCodeByLocale ( $ locale ) { if ( str_contains ( $ locale , ' ' ) ) { $ locale = str_replace ( ' ' , '-' , $ locale ) ; } if ( strlen ( $ locale ) == 2 ) { if ( $ locale == 'en' ) { $ locale = 'en-US' ; } else { $ locale = $ locale . '-' . strtoupper ( $ locale ) ; } } return Locale :: getRegion (...
Get Country code by Locale
232,215
public function extractHashtags ( $ str , $ type = 'arr' ) { preg_match_all ( "/(#\w+)/" , $ str , $ matches ) ; $ matches = $ type == 'arr' ? $ matches [ 0 ] : implode ( ', ' , $ matches [ 0 ] ) ; return $ matches ; }
Extract hashtags from strings
232,216
public function summaryNumbers ( $ number ) { $ x = round ( $ number ) ; $ x_number_format = number_format ( $ x ) ; $ x_array = explode ( ',' , $ x_number_format ) ; $ x_parts = [ 'k' , 'm' , 'b' , 't' ] ; $ x_count_parts = count ( $ x_array ) - 1 ; $ x_display = $ x ; if ( ! isset ( $ x_array [ 1 ] ) ) { return $ x_a...
Format numbers in instagram followers style
232,217
public function urlWithParams ( $ path = null , $ qs = [ ] , $ secure = null ) { $ url = app ( 'url' ) -> to ( $ path , $ secure ) ; if ( count ( $ qs ) ) { foreach ( $ qs as $ key => $ value ) { $ qs [ $ key ] = sprintf ( '%s=%s' , $ key , urlencode ( $ value ) ) ; } $ url = sprintf ( '%s?%s' , $ url , implode ( '&' ,...
Laravel route with query strings
232,218
public function getRoutesName ( $ contains = null , $ exact = true ) { $ routeCollection = \ Route :: getRoutes ( ) ; $ routes = collect ( $ routeCollection ) -> map ( function ( $ item ) { return $ item -> getName ( ) ; } ) -> filter ( function ( $ item ) { return ! is_null ( $ item ) ; } ) -> values ( ) ; if ( $ cont...
Get all routes name
232,219
public function getAllKeysRoutes ( ) { $ routeCollection = \ Route :: getRoutes ( ) ; $ routes = collect ( $ routeCollection ) -> map ( function ( $ item ) { return explode ( '/' , $ item -> getPrefix ( ) ) ; } ) -> values ( ) -> collapse ( ) -> filter ( function ( $ item , $ key ) { return $ item !== '' ; } ) -> group...
Get all keys of routes
232,220
public function getScheduledJobs ( ) { $ jobs = [ ] ; foreach ( $ this -> jobs as $ job ) { $ model = CronJob :: find ( $ job [ 'id' ] ) ; if ( ! $ model ) { $ model = new CronJob ( ) ; $ model -> id = $ job [ 'id' ] ; $ model -> save ( ) ; } $ params = new DateParameters ( $ job ) ; $ date = new CronDate ( $ params , ...
Gets all of the jobs scheduled to run now .
232,221
public function runScheduled ( OutputInterface $ output ) { $ success = true ; $ event = new ScheduleRunBeginEvent ( ) ; $ this -> dispatcher -> dispatch ( $ event :: NAME , $ event ) ; foreach ( $ this -> getScheduledJobs ( ) as $ jobInfo ) { $ job = $ jobInfo [ 'model' ] ; $ run = $ this -> runJob ( $ job , $ jobInfo...
Runs any scheduled tasks .
232,222
public function add ( ModelObject $ obj ) { $ obj -> CreationDate = $ this -> DateFactory -> newStorageDate ( ) ; if ( ! $ obj -> hasModifiedDate ( ) ) $ obj -> ModifiedDate = $ this -> DateFactory -> newStorageDate ( ) ; $ this -> validator -> validateFor ( __FUNCTION__ , $ obj ) -> throwOnError ( ) ; return $ this ->...
Performs an INSERT for the given ModelObject through our DAO . CreationDate and ModifiedDate are set and the validator is run
232,223
public function edit ( ModelObject $ obj ) { if ( ! $ obj -> hasModifiedDate ( ) ) $ obj -> ModifiedDate = $ this -> DateFactory -> newStorageDate ( ) ; $ this -> validator -> validateFor ( __FUNCTION__ , $ obj ) -> throwOnError ( ) ; return $ this -> dao -> edit ( $ obj ) ; }
Performs an UPDATE for the given ModelObject through our DAO . ModifiedDate is updated and the validator is run .
232,224
public function delete ( $ objSlug ) { $ this -> validator -> validateFor ( __FUNCTION__ , $ objSlug ) -> throwOnError ( ) ; return $ this -> dao -> delete ( $ objSlug ) ; }
Performs a DELETE for the given slug through our DAO . The validator is run .
232,225
public function getSerializationType ( ) { switch ( $ this -> association ) { case self :: ASSOCIATION_TYPE_EMBED_ONE : case self :: ASSOCIATION_TYPE_EMBED_MANY : return TypeFactory :: getType ( Type :: MAP ) ; case self :: ASSOCIATION_TYPE_REFERENCE_ONE : case self :: ASSOCIATION_TYPE_REFERENCE_MANY : return $ this ->...
Return the Type used to serialize individual association values .
232,226
private function makeReflection ( ) { if ( $ this -> reflection === null ) { $ this -> reflection = new \ ReflectionProperty ( $ this -> className , $ this -> name ) ; $ this -> reflection -> setAccessible ( true ) ; } }
Retrieve and store reflection metadata for this property from php internals .
232,227
public function mapAttribute ( ClassMetadata $ class ) { $ this -> applyDefaults ( ) ; $ this -> validate ( ) ; $ this -> makeGenerator ( ) ; $ class -> addAttributeMapping ( $ this ) ; }
Map this property as an attribute .
232,228
public function mapManyEmbedded ( ClassMetadata $ class , $ type = Type :: LIST_ ) { $ this -> embedded = true ; $ this -> type = $ type ; $ this -> mapAttribute ( $ class ) ; }
Map this property as a collection of embedded documents .
232,229
public function mapManyReference ( ClassMetadata $ class , $ type = Type :: LIST_ ) { $ this -> reference = true ; $ this -> type = $ type ; $ this -> mapAttribute ( $ class ) ; }
Map this property as a collection of document references .
232,230
public function mapOneEmbedded ( ClassMetadata $ class ) { $ this -> embedded = true ; $ this -> type = self :: TYPE_ONE ; $ this -> mapAttribute ( $ class ) ; }
Map this property as a single embedded document .
232,231
public function mapOneReference ( ClassMetadata $ class ) { $ this -> reference = true ; $ this -> type = self :: TYPE_ONE ; $ this -> mapAttribute ( $ class ) ; }
Map this property as a single document reference .
232,232
public function setValueAndWakeProxy ( $ document , $ value ) { if ( $ document instanceof Proxy && ! $ document -> __isInitialized ( ) ) { $ document -> __load ( ) ; } $ this -> setValue ( $ document , $ value ) ; return $ this ; }
Sets this mapped attribute to the specified value on the given document waking the document if proxied .
232,233
public function addOpeningHour ( $ day , $ hours ) { $ openingHour = new OpeningHours ( $ day , $ hours ) ; $ this -> openingHours [ $ day ] = $ openingHour ; }
Adds an opening schedule for a day .
232,234
public function sanitize ( $ value ) { if ( $ value instanceof Traversable ) { return $ this -> sanitize ( iterator_to_array ( $ value ) ) ; } elseif ( is_array ( $ value ) ) { return array_map ( [ $ this , 'sanitize' ] , $ value ) ; } elseif ( is_object ( $ value ) ) { return $ this -> sanitizeObject ( $ value ) ; } e...
Sanitize recursively a value
232,235
public function indexAction ( ) { $ configForm = $ this -> getForm ( ) ; $ configForm -> setData ( $ this -> getConfig ( ) ) ; $ view = new ViewModel ( array ( 'title' => $ this -> getEditTitle ( ) , 'configForm' => $ configForm ) ) ; $ view -> setTemplate ( 'xelax-site-config/site-config/index.phtml' ) ; return $ view...
Show current config
232,236
public static function create ( string $ name , $ value , array $ expectedTypes ) : self { return new static ( sprintf ( '%s expected to be %s, %s returned' , ucfirst ( $ name ) , implode ( ' or ' , $ expectedTypes ) , is_object ( $ value ) ? get_class ( $ value ) : gettype ( $ value ) ) ) ; }
Makes an exception instance .
232,237
protected function loadExchangeRates ( $ targetCurrency ) { if ( ! isset ( $ this -> exchangeRates [ $ targetCurrency ] ) ) { $ currencyRates = $ this -> currencyRateRepository -> findBy ( [ 'currencyTo' => $ targetCurrency ] ) ; if ( count ( $ currencyRates ) === 0 ) { throw new MissingCurrencyRatesException ( $ targe...
Sets exchange rates for target currency
232,238
public function get ( $ ressourceToGrab , array $ parameters = null ) { $ this -> apiRequest -> clean ( ) ; $ this -> apiRequest -> setHeaders ( $ this -> apiConfiguration -> getHeaders ( ) ) ; $ this -> apiRequest -> setParameters ( $ this -> apiConfiguration -> getParameters ( ) ) ; return $ this -> apiRequest -> get...
Request a ressource of an api with the get http method
232,239
protected function substituteBindings ( $ route ) { foreach ( $ route -> parameters ( ) as $ key => $ value ) { if ( isset ( $ this -> binders [ $ key ] ) ) { $ route -> setParameter ( $ key , $ this -> performBinding ( $ key , $ value , $ route ) ) ; } } $ this -> substituteImplicitBindings ( $ route ) ; return $ rout...
Substitute the route bindings onto the route .
232,240
protected function substituteImplicitBindings ( $ route ) { $ parameters = $ route -> parameters ( ) ; foreach ( $ route -> signatureParameters ( Model :: class ) as $ parameter ) { $ class = $ parameter -> getClass ( ) ; if ( array_key_exists ( $ parameter -> name , $ parameters ) && ! $ route -> getParameter ( $ para...
Substitute the implicit Eloquent model bindings for the route .
232,241
public function bindParam ( $ param , & $ variable , $ type = null , int $ length = null ) : bool { try { return $ this -> pdoStatement -> bindParam ( $ param , $ variable , $ type , $ length , null ) ; } catch ( PDOException $ pdoe ) { throw new DatabaseException ( $ pdoe -> getMessage ( ) , $ pdoe ) ; } }
bind a parameter of a prepared query to the specified variable
232,242
public function bindValue ( $ param , $ value , $ type = null ) : bool { try { return $ this -> pdoStatement -> bindValue ( $ param , $ value , $ type ) ; } catch ( PDOException $ pdoe ) { throw new DatabaseException ( $ pdoe -> getMessage ( ) , $ pdoe ) ; } }
bind a value to the parameter of a prepared query
232,243
public function execute ( array $ values = [ ] ) : QueryResult { try { if ( $ this -> pdoStatement -> execute ( $ values ) ) { return new PdoQueryResult ( $ this -> pdoStatement ) ; } throw new DatabaseException ( 'Executing the prepared statement failed.' ) ; } catch ( PDOException $ pdoe ) { throw new DatabaseExcepti...
executes a prepared statement
232,244
public function filterByHost ( $ host = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ host ) ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( SourceTableMap :: COL_HOST , $ host , $ comparison ) ; }
Filter the query on the host column
232,245
public function filterByEndpoint ( $ endpoint = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ endpoint ) ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( SourceTableMap :: COL_ENDPOINT , $ endpoint , $ comparison ) ; }
Filter the query on the endpoint column
232,246
public function indexAction ( ) { $ instances = $ this -> getManager ( ) -> findAll ( ) ; $ worker = $ this -> get ( 'ringo_php_redmon.instance_worker' ) ; if ( is_array ( $ instances ) ) { foreach ( $ instances as $ index => $ instance ) { $ working = $ worker -> setInstance ( $ instance ) -> ping ( ) ; $ instances [ ...
List of instances action
232,247
public function editAction ( $ id ) { $ instance = $ this -> getManager ( ) -> find ( $ id ) ; if ( ! $ instance ) { return new RedirectResponse ( $ this -> generateUrl ( 'ringo_php_redmon' ) ) ; } $ form = $ this -> getForm ( $ instance ) ; return $ this -> render ( $ this -> getTemplatePath ( ) . 'edit.html.twig' , a...
Edit instance action
232,248
public function updateAction ( $ id ) { $ form = $ this -> getForm ( ) ; $ request = $ this -> get ( 'request' ) ; if ( 'POST' == $ request -> getMethod ( ) ) { $ form -> submit ( $ request ) ; if ( $ form -> isValid ( ) ) { $ this -> getManager ( ) -> create ( $ form -> getData ( ) ) ; $ this -> get ( 'session' ) -> g...
Update instance action
232,249
public function deleteAction ( $ id ) { $ instance = $ this -> getManager ( ) -> find ( $ id ) ; if ( $ instance ) { $ this -> getManager ( ) -> delete ( $ instance ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'Instance Redis has been deleted successfully' ) ; } else { $ this -> get ( 'sessio...
Delete instance action
232,250
protected function getForm ( Instance $ instance = null ) { if ( $ instance == null ) { $ instance = $ this -> getManager ( ) -> createNew ( ) ; } return $ this -> createForm ( $ this -> container -> get ( 'ringo_php_redmon.form.instance_type' ) , $ instance ) ; }
Create Form instance
232,251
public function attribute ( $ name ) { $ exists = isset ( $ this -> attributes [ $ name ] ) ; return $ exists ? $ this -> attributes [ $ name ] : null ; }
Returns an instance with the specified derived request attribute .
232,252
public function query ( $ name ) { $ exists = isset ( $ this -> queries [ $ name ] ) ; return $ exists ? $ this -> queries [ $ name ] : null ; }
Returns the specified query string argument .
232,253
protected function longestCommonSubsequence ( array $ from , array $ to ) { $ common = array ( ) ; $ matrix = array ( ) ; $ fromLength = count ( $ from ) ; $ toLength = count ( $ to ) ; for ( $ i = 0 ; $ i <= $ fromLength ; ++ $ i ) { $ matrix [ $ i ] [ 0 ] = 0 ; } for ( $ j = 0 ; $ j <= $ toLength ; ++ $ j ) { $ matri...
Calculates the longest common subsequence of two arrays .
232,254
private function getDwnlLog ( $ datestamp ) { $ result = [ ] ; $ tsFrom = $ this -> hlpPeriod -> getTimestampFrom ( $ datestamp ) ; $ periodTo = $ this -> hlpPeriod -> getPeriodCurrent ( ) ; $ tsTo = $ this -> hlpPeriod -> getTimestampTo ( $ periodTo ) ; $ query = $ this -> qGetChanges -> build ( ) ; $ conn = $ query -...
Load change log starting from the given date .
232,255
private function getDwnlSnap ( $ datestamp ) { $ result = [ ] ; $ query = $ this -> qSnapOnDate -> build ( ) ; $ query -> order ( QSnapOnDate :: AS_DWNL_SNAP . '.' . ESnap :: A_DEPTH ) ; $ conn = $ query -> getConnection ( ) ; $ bind = [ QSnapOnDate :: BND_ON_DATE => $ datestamp ] ; $ rows = $ conn -> fetchAll ( $ quer...
Load downline snapshot on the given date .
232,256
public static function getAnonymous ( ) : Principal { if ( self :: $ anon === null ) { self :: $ anon = new self ( null , [ ] , true ) ; } return self :: $ anon ; }
Gets a token representing an anonymous authentication .
232,257
public function validateConnection ( ) { if ( $ this -> validate ( ) ) { try { $ connection = new CDbConnection ( "mysql:host={$this->host};dbname={$this->dbname}" , $ this -> username , $ this -> password ) ; $ connection -> setActive ( true ) ; $ connection -> setActive ( false ) ; $ this -> dsn = $ connection -> con...
Validator for connection to MySQL
232,258
private function contents ( ) : array { if ( ! $ this -> contents ) { if ( ! file_exists ( $ this -> path ) ) { throw new \ LogicException ( vsprintf ( 'The PHP configuration file does not exist (%s)' , [ realpath ( $ this -> path ) , ] ) ) ; } $ contents = require $ this -> path ; if ( ! is_array ( $ contents ) ) { th...
Return the content of the file and cache it .
232,259
private function keyNotArrayErrorMessage ( array $ contents , string ... $ path ) : string { $ value = array_reduce ( $ path , function ( array $ arr , string $ key ) { return $ arr [ $ key ] ; } , $ contents ) ; return vsprintf ( 'The key [%s] of the configuration array must be an array, %s given (%s)' , [ implode ( '...
Return the error message of the exception thrown when a key of the configuration array is not an array .
232,260
private function arrayKeyTypeErrorMessage ( array $ contents , string $ key , string $ type , string ... $ path ) : string { $ arr = array_reduce ( $ path , function ( array $ arr , string $ key ) { return $ arr [ $ key ] ; } , $ contents ) ; return vsprintf ( 'The key [%s] of the configuration array must be an array o...
Return the error message of the exception thrown when a key of an array is associated to a value with an unexpected type .
232,261
static function instance ( array $ whitelist , array $ blacklist , array $ aliaslist , $ main_entity_id = \ hlin \ Auth :: Unidentified , $ main_entity_role = \ hlin \ Auth :: Guest , \ hlin \ archetype \ Logger $ logger = null ) { $ i = new static ; $ i -> whitelist = $ whitelist ; $ i -> blacklist = $ blacklist ; $ i...
Most operations are on the current entity so we require the current entity is set to facilitate the process ; some operations also require the current entity to resolve .
232,262
public function overrideGlobals ( ) { $ this -> server -> set ( 'QUERY_STRING' , static :: normalizeQueryString ( http_build_query ( $ this -> query -> all ( ) , NULL , '&' ) ) ) ; $ _GET = $ this -> query -> all ( ) ; $ _POST = $ this -> request -> all ( ) ; $ _SERVER = $ this -> server -> all ( ) ; $ _COOKIE = $ this...
Overrides the PHP global variables according to this request instance .
232,263
public static function setTrustedHosts ( array $ hostPatterns ) { self :: $ trustedHostPatterns = array_map ( function ( $ hostPattern ) { return sprintf ( '#%s#i' , $ hostPattern ) ; } , $ hostPatterns ) ; self :: $ trustedHosts = [ ] ; }
Sets a list of trusted host patterns . You should only list the hosts you manage using regexs .
232,264
protected function getContents ( $ path ) { $ contents = @ file_get_contents ( $ path ) ; if ( false === $ contents ) { throw new NotFoundException ( Message :: get ( Message :: CONFIG_FILE_NOTFOUND , $ path ) , Message :: CONFIG_FILE_NOTFOUND ) ; } return $ contents ; }
Read contents from a local file system
232,265
protected function matchEnv ( $ name ) { if ( '_' === $ name [ 0 ] ) { $ pos = strpos ( $ name , '.' ) ; if ( false !== $ pos ) { $ pref = substr ( $ name , 0 , $ pos ) ; $ suff = substr ( $ name , $ pos + 1 ) ; if ( isset ( $ GLOBALS [ $ pref ] [ $ suff ] ) ) { return $ GLOBALS [ $ pref ] [ $ suff ] ; } } } return get...
Find the env value base one the name
232,266
public static function permissionType ( $ type ) { if ( $ type == Teamspeak :: PERM_TYPE_SERVERGROUP ) { return "Server Group" ; } if ( $ type == Teamspeak :: PERM_TYPE_CLIENT ) { return "Client" ; } if ( $ type == Teamspeak :: PERM_TYPE_CHANNEL ) { return "Channel" ; } if ( $ type == Teamspeak :: PERM_TYPE_CHANNELGROU...
Converts a given permission type ID to a human readable name .
232,267
public function validateUniqueness ( $ entity , $ parameters ) { $ errors = new Collection ( ) ; foreach ( $ this -> getManager ( ) -> getUnique ( ) as $ name => $ attributes ) { $ q = $ this -> getManager ( ) -> getRepository ( ) -> getQuery ( ) ; $ where = collect ( ) ; foreach ( $ attributes as $ attribute ) { $ att...
Validate uniqueness .
232,268
protected function achieveSerializer ( string $ mime ) : S \ ASerializer { $ this -> checkSerializerSupported ( $ mime ) ; $ serializer = $ this -> getSerializer ( $ mime ) ; return static :: instantiateSerializer_ ( $ serializer ) ; }
Static method achieveSerializer
232,269
public function handler ( $ severity , $ message , $ file , $ line ) { throw new ErrorException ( $ message , 0 , $ severity , $ file , $ line ) ; }
Error handler . Throw new Eureka ErrorException
232,270
public function toObject ( ) { $ array = $ this -> get ( ) ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ array [ $ key ] = ( new \ PHY \ Variable \ Arr ( $ value ) ) -> toObject ( ) ; } } return ( object ) $ array ; }
Recursively convert our array into a stdClass .
232,271
public function offsetGet ( $ offset ) { $ get = $ this -> chaining ? 'chain' : 'current' ; return array_key_exists ( $ offset , $ this -> $ get ) ? $ this -> $ get [ $ offset ] : null ; }
Grab an offset if it s defined .
232,272
public function offsetSet ( $ offset , $ value ) { $ get = $ this -> chaining ? 'chain' : 'current' ; $ this -> $ get [ $ offset ] = $ value ; }
Set an offset .
232,273
public function sort ( $ sort_flags = SORT_REGULAR ) { $ array = $ this -> get ( ) ; sort ( $ array , $ sort_flags ) ; $ this -> update ( $ array ) ; return $ this ; }
Sort our Array .
232,274
public function slice ( $ offset = 0 , $ length = null , $ preserve_keys = false ) { $ array = array_slice ( $ this -> get ( ) , $ offset , $ length , $ preserve_keys ) ; $ this -> update ( $ array ) ; return $ this ; }
Slice an Array .
232,275
public function splice ( $ offset = 0 , $ length = 0 , $ replacement = null ) { $ array = $ this -> get ( ) ; if ( null !== $ replacement ) { array_splice ( $ array , $ offset , $ length , $ replacement ) ; } else { array_splice ( $ array , $ offset , $ length ) ; } $ this -> update ( $ array ) ; return $ this ; }
Splice an array .
232,276
public function create ( $ keyName = 'id' , $ route_key_name = 'id' , $ timestamps = true , $ softDeletes = false , $ fields = [ ] ) { $ path = $ this -> getpath ( $ this -> name ) ; if ( $ this -> files -> exists ( $ path ) ) { throw new \ Exception ( "Model [$this->name] already exists!" ) ; } $ stub = $ this -> file...
Create a new migration file .
232,277
protected function replaceFillable ( & $ stub , $ fields ) { $ fillable = [ ] ; foreach ( $ fields as $ f ) { if ( $ f [ 'add_to' ] == 'fillable' ) $ fillable [ ] = "\"{$f['name']}\"" ; } if ( count ( $ fillable ) ) $ fillable = "protected \$fillable = [" . implode ( ',' , $ fillable ) . "];" ; else $ fillable = "" ; $...
Replace fillable dummy .
232,278
protected function replaceGuarded ( & $ stub , $ fields ) { $ guarded = [ ] ; foreach ( $ fields as $ f ) { if ( $ f [ 'add_to' ] == 'guarded' ) $ guarded [ ] = "\"{$f['name']}\"" ; } if ( count ( $ guarded ) ) $ guarded = "protected \$guarded = [" . implode ( ',' , $ guarded ) . "];" ; else $ guarded = "" ; $ stub = s...
Replace guarded dummy .
232,279
protected function replaceCasts ( & $ stub , $ fields ) { $ casts = [ ] ; foreach ( $ fields as $ f ) { if ( ! empty ( $ f [ 'casts' ] ) ) $ casts [ ] = "\"{$f['name']}\"=>\"{$f['casts']}\"" ; } if ( count ( $ casts ) ) $ casts = "protected \$casts = [" . implode ( ',' , $ casts ) . "];" ; else $ casts = "" ; $ stub = ...
Replace casts dummy .
232,280
protected function replaceRouteKeyName ( & $ stub , $ route_key_name ) { if ( $ route_key_name == 'id' ) $ replace = "" ; else { $ replace = "public function getRouteKeyName(){ return \"{$route_key_name}\"; }" ; } $ stub = str_replace ( 'DummyRouteKeyName' , $ replace , $ stub ) ; return $ this ; }
Replace RouteKeyName dummy .
232,281
public function getFileByName ( $ folderName , $ mimeType , $ includeTrash = false , \ Google_Service_Drive_DriveFile $ parent = null , $ createIfNotFound = false ) { $ query = 'title = \'' . $ folderName . '\' and mimeType = \'' . $ mimeType . '\'' ; if ( ! $ includeTrash ) { $ query .= ' and trashed = false' ; } if (...
Get a file
232,282
public function downloadFileFromURL ( $ url ) { $ request = new \ Google_Http_Request ( $ url , 'GET' , null , null ) ; $ httpRequest = $ this -> service -> getClient ( ) -> getAuth ( ) -> authenticatedRequest ( $ request ) ; if ( $ httpRequest -> getResponseHttpCode ( ) == 200 ) { return $ httpRequest -> getResponseBo...
Download a file from a url
232,283
public function getFilesInFolder ( \ Google_Service_Drive_DriveFile $ folder ) { $ query = 'trashed = false and \'' . $ folder -> getId ( ) . '\' in parents' ; $ fileList = $ this -> service -> files -> listFiles ( array ( 'q' => $ query ) ) ; return $ fileList ; }
Get Files in a folder
232,284
private function checkImage ( $ path ) { if ( ! file_exists ( $ this -> getWebDirectory ( ) . '/' . $ path ) && ! file_exists ( $ path ) ) { throw new NotFoundException ( sprintf ( "Unable to find the image \"%s\" to cache" , $ path ) ) ; } if ( ! is_file ( $ this -> getWebDirectory ( ) . '/' . $ path ) && ! is_file ( ...
Validates that an image exists
232,285
public static function translate ( $ url , $ options = array ( ) ) { if ( ( $ embed = \ Phata \ Widgetfy \ Site :: translate ( $ url , $ options ) ) != NULL ) { return $ embed ; } elseif ( ( $ embed = \ Phata \ Widgetfy \ MediaFile :: translate ( $ url , $ options ) ) != NULL ) { return $ embed ; } return NULL ; }
simplified interface to translate a url into embed code
232,286
public static function between ( int $ min , int $ max , string $ encoding = 'UTF-8' ) : Length { $ length = [ $ min , $ max ] ; sort ( $ length ) ; return new Length ( 'bt' , $ length , $ encoding ) ; }
Gets a rule that requires strings to have a minimum and maximum length .
232,287
protected function BeforeGather ( ) { if ( $ this -> IsTriggered ( ) && $ this -> Elements ( ) -> Check ( Request :: MethodArray ( $ this -> Method ( ) ) ) ) { return $ this -> OnSuccess ( ) ; } return parent :: BeforeGather ( ) ; }
Overrides the template module method to realize form logic
232,288
protected function SetRequired ( $ name , $ errorPrefix = '' ) { $ field = $ this -> GetElement ( $ name ) ; if ( ! $ field instanceof FormField ) { throw new \ InvalidArgumentException ( "$name is not a field in the form elements" ) ; } if ( ! $ errorPrefix ) { $ errorPrefix = $ this -> ErrorPrefix ( $ name ) ; } $ fi...
Sets the field as required
232,289
public function GetElement ( $ name ) { $ element = $ this -> Elements ( ) -> GetElement ( $ name ) ; if ( ! $ element ) { throw new \ Exception ( Trans ( 'Core.Form.Error.ElementNotFound.Name_{0}' , $ name ) ) ; } return $ element ; }
Gets the element with the given name
232,290
protected function AddValidator ( $ name , Validator $ validator , $ errorPrefix = '' ) { $ field = $ this -> GetElement ( $ name ) ; if ( ! $ errorPrefix ) { $ errorPrefix = $ this -> ErrorPrefix ( $ name ) ; } $ validator -> SetErrorLabelPrefix ( $ errorPrefix ) ; $ field -> AddValidator ( $ validator ) ; }
Adds a validator to the name
232,291
protected function AddSubmit ( $ name = '' , $ label = '' ) { $ defaultLabel = $ this -> Label ( 'Submit' ) ; if ( ! $ name ) { $ name = str_replace ( '.' , '-' , $ defaultLabel ) ; } if ( ! $ label ) { $ label = Worder :: Replace ( $ defaultLabel ) ; } $ this -> triggerName = $ name ; $ field = new Submit ( $ name , $...
Adds a submit button that triggers the form logic on submit
232,292
protected function Value ( $ name , $ trim = true ) { $ value = Request :: MethodData ( $ this -> Method ( ) , $ name ) ; if ( $ trim ) { return Str :: Trim ( $ value ) ; } return $ value ; }
The form value as submitted
232,293
protected function FindSnippet ( IFormField $ field ) { if ( $ field instanceof Input && ( $ field -> GetType ( ) == Input :: TypeText || $ field -> GetType ( ) == Input :: TypePassword || $ field -> GetType ( ) == Input :: TypeColor ) ) { return new FormFields \ TextInputField ( $ field ) ; } if ( $ field instanceof I...
Finds the snippet for a form field ; can be overriden for customization
232,294
protected function SetTransAttribute ( $ name , $ attribute ) { $ field = $ this -> GetElement ( $ name ) ; $ field -> SetHtmlAttribute ( $ attribute , Worder :: Replace ( $ this -> AttributePlaceholder ( $ name , $ attribute ) ) ) ; }
Sets a translatable attribute of the field to a default placeholder
232,295
protected function SetTransDescription ( $ name ) { $ field = $ this -> GetElement ( $ name ) ; $ field -> SetDescription ( Worder :: Replace ( $ this -> FieldDescription ( $ name ) ) ) ; }
Sets a description with a default placeholder for translation
232,296
protected function _loadDocument ( ) { $ this -> _Document = new DOMDocument ( ) ; $ reporting = error_reporting ( 0 ) ; $ loaded = $ this -> _Document -> loadHTML ( $ this -> _html ) ; error_reporting ( $ reporting ) ; if ( ! $ loaded ) { throw new Exception ( 'Unable to load HTML document.' ) ; } }
Builds a DOMDocument from the HTML source .
232,297
public static function path ( string $ path ) : string { if ( ! isset ( self :: $ cache [ $ path ] ) ) { $ _path = preg_replace ( '#\\' . static :: DIRECTORY_SEPARATOR . '+#' , static :: DIRECTORY_SEPARATOR , ltrim ( $ path , static :: DIRECTORY_SEPARATOR ) ) ; $ tmp = explode ( static :: DIRECTORY_SEPARATOR , $ _path ...
Normalize the given path
232,298
public static function directory ( string $ path ) : string { return ltrim ( rtrim ( $ path , static :: DIRECTORY_SEPARATOR ) . static :: DIRECTORY_SEPARATOR , static :: DIRECTORY_SEPARATOR ) ; }
Force path to be a directory
232,299
public static function setNestedObjectProperty ( $ value , & $ object , $ memberPath ) { $ explodedPath = explode ( "." , $ memberPath ) ; $ finalBit = array_pop ( $ explodedPath ) ; if ( sizeof ( $ explodedPath ) > 0 ) { $ nestedProperty = ObjectUtils :: getNestedObjectProperty ( $ object , implode ( "." , $ explodedP...
Set a nested object property value on an object using a member path to locate it .