idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
56,300
|
public static function b ( $ name , $ options = [ ] ) { $ options = array_merge ( $ options , [ 'type' => 'submit' ] ) ; return static :: socialButton ( $ name , $ options ) -> tag ( 'button' ) ; }
|
Creates a SocialButton component as a button tag
|
56,301
|
public function getCyrMap ( ) { if ( null === $ this -> cyrMap ) { $ this -> cyrMap = $ this -> getTransliterationMap ( Settings :: ALPHABET_CYR ) ; } return $ this -> cyrMap ; }
|
Get cyrillic char map .
|
56,302
|
public function getLatMap ( ) { if ( null === $ this -> latMap ) { $ this -> latMap = $ this -> getTransliterationMap ( Settings :: ALPHABET_LAT ) ; } return $ this -> latMap ; }
|
Get latin char map .
|
56,303
|
public function setIds ( array $ ids ) : void { if ( empty ( $ ids ) ) { throw new \ InvalidArgumentException ( 'At least one ID must be specified' ) ; } foreach ( $ ids as $ id ) { if ( ! \ is_int ( $ id ) ) { throw new \ InvalidArgumentException ( 'All IDs must be integers' ) ; } } $ this -> ids = $ ids ; }
|
A comma - separated list of numeric IDs for individual items in the feed .
|
56,304
|
private function registerGuzzlePlugin ( Definition $ clientDefinition , array $ plugins ) { foreach ( $ plugins as $ pluginId => $ attributes ) { $ clientDefinition -> addMethodCall ( 'addSubscriber' , array ( new Reference ( $ pluginId ) ) ) ; } }
|
Register plugin for a client
|
56,305
|
public function resolve ( string $ service ) : ResolveAllUrlsResponse { $ key = $ this -> cacheKey ( $ service ) ; $ item = $ this -> cache -> getItem ( $ key ) ; if ( $ item -> isHit ( ) ) { return $ item -> get ( ) ; } $ options = [ 'query' => [ 'schema' => self :: SCHEMA_VERSION , '_service' => $ service , ] , ] ; $ response = $ this -> authenticatedClient -> request ( 'GET' , static :: RESOLVE_ALL_URLS_URL , $ options ) ; $ encoders = [ new JsonEncoder ( ) ] ; $ normalizers = [ new UriNormalizer ( ) , new ObjectNormalizer ( null , null , null , new PhpDocExtractor ( ) ) , new ArrayDenormalizer ( ) ] ; $ serializer = new Serializer ( $ normalizers , $ encoders ) ; $ resolved = $ serializer -> deserialize ( $ response -> getBody ( ) , ResolveAllUrlsResponse :: class , 'json' ) ; $ resolved -> setService ( $ service ) ; $ this -> saveCache ( $ key , $ resolved ) ; return $ resolved ; }
|
Fetch URLs and return the response .
|
56,306
|
public function getMapFilePath ( ) { return sprintf ( '%s.php' , $ this -> mapBasePath . DIRECTORY_SEPARATOR . $ this -> getLang ( ) . DIRECTORY_SEPARATOR . $ this -> getSystem ( ) ) ; }
|
Get path to map file depending on current settings .
|
56,307
|
public function setSystem ( $ system ) { if ( ! in_array ( $ system , $ this -> getSupportedTranliterationSystems ( ) ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Transliteration system "%s" is not supported for "%s" language.' , $ system , $ this -> getLang ( ) ) ) ; } $ this -> system = $ system ; return $ this ; }
|
Set transliteration system .
|
56,308
|
public function getSupportedLanguages ( ) { return array ( self :: LANG_SR , self :: LANG_RU , self :: LANG_BE , self :: LANG_MK , self :: LANG_UK , self :: LANG_BG , self :: LANG_EL ) ; }
|
Get suported languages .
|
56,309
|
public function getSupportedTranliterationSystems ( ) { $ default = array ( self :: SYSTEM_DEFAULT ) ; switch ( $ this -> getLang ( ) ) { case self :: LANG_RU : return array_merge ( $ default , array ( self :: SYSTEM_ISO_R_9_1968 , self :: SYSTEM_GOST_1971 , self :: SYSTEM_GOST_1983 , self :: SYSTEM_GOST_2000_B , self :: SYSTEM_GOST_2002 , self :: SYSTEM_ALA_LC , self :: SYSTEM_British_Standard , self :: SYSTEM_BGN_PCGN , self :: SYSTEM_Passport_2003 ) ) ; break ; case self :: LANG_BE : return array_merge ( $ default , array ( self :: SYSTEM_ALA_LC , self :: SYSTEM_BGN_PCGN , self :: SYSTEM_ISO_9 , self :: SYSTEM_National_2000 ) ) ; break ; case self :: LANG_MK : return array_merge ( $ default , array ( self :: SYSTEM_ISO_9_1995 , self :: SYSTEM_BGN_PCGN , self :: SYSTEM_ISO_9_R_1968_National_Academy , self :: SYSTEM_ISO_9_R_1968_b ) ) ; break ; case self :: LANG_UK : return array_merge ( $ default , array ( self :: SYSTEM_ALA_LC , self :: SYSTEM_British , self :: SYSTEM_BGN_PCGN , self :: SYSTEM_ISO_9 , self :: SYSTEM_National , self :: SYSTEM_GOST_1971 , self :: SYSTEM_GOST_1986 , self :: SYSTEM_Derzhstandart_1995 , self :: SYSTEM_Passport_2004 , self :: SYSTEM_Passport_2007 , self :: SYSTEM_Passport_2010 ) ) ; break ; case self :: LANG_BG : case self :: LANG_EL : break ; } return $ default ; }
|
Get suported transliteration systems for current language .
|
56,310
|
public function loadByNumericId ( int $ id , bool $ readonly = false , array $ options = [ ] ) { $ annotation = $ this -> dataService -> getAnnotation ( ) ; $ base = $ this -> getBaseUri ( $ annotation , $ readonly ) ; $ uri = new Uri ( $ base . '/' . $ id ) ; return $ this -> load ( $ uri , $ options ) ; }
|
Load a data object from MPX returning a promise to it .
|
56,311
|
protected function deserialize ( $ data , string $ class ) { $ dataServiceExtractor = new DataServiceExtractor ( ) ; $ dataServiceExtractor -> setClass ( $ this -> dataService -> getClass ( ) ) ; $ dataServiceExtractor -> setCustomFields ( $ this -> dataService -> getCustomFields ( ) ) ; $ decoded = \ GuzzleHttp \ json_decode ( $ data , true ) ; if ( isset ( $ decoded [ '$xmlns' ] ) ) { $ dataServiceExtractor -> setNamespaceMapping ( $ decoded [ '$xmlns' ] ) ; } $ p = new PropertyInfoExtractor ( [ ] , [ $ dataServiceExtractor ] , [ ] , [ ] ) ; $ cached = new PropertyInfoCacheExtractor ( $ p , $ this -> cacheItemPool ) ; $ object = $ this -> getObjectSerializer ( $ cached ) -> deserialize ( $ data , $ class , 'json' ) ; if ( $ object instanceof ObjectInterface ) { $ customFields = $ object -> getCustomFields ( ) ; $ remaining = array_diff_key ( $ this -> dataService -> getCustomFields ( ) , $ customFields ) ; foreach ( $ remaining as $ namespace => $ field ) { $ namespaceClass = $ field -> getClass ( ) ; $ customFields [ $ namespace ] = new $ namespaceClass ( ) ; } $ object -> setCustomFields ( $ customFields ) ; } if ( $ object instanceof JsonInterface ) { $ object -> setJson ( $ data ) ; } return $ object ; }
|
Deserialize a JSON string into a class .
|
56,312
|
public function load ( UriInterface $ uri , array $ options = [ ] ) : PromiseInterface { $ annotation = $ this -> dataService -> getAnnotation ( ) ; if ( ! isset ( $ options [ 'query' ] ) ) { $ options [ 'query' ] = [ ] ; } $ options [ 'query' ] = $ options [ 'query' ] += [ 'schema' => $ annotation -> schemaVersion , 'form' => 'cjson' , ] ; if ( $ this -> authenticatedClient -> hasAccount ( ) ) { $ options [ 'query' ] [ 'account' ] = ( string ) $ this -> authenticatedClient -> getAccount ( ) -> getMpxId ( ) ; } if ( 'http' == $ uri -> getScheme ( ) ) { $ uri = $ uri -> withScheme ( 'https' ) ; } $ response = $ this -> authenticatedClient -> requestAsync ( 'GET' , $ uri , $ options ) -> then ( function ( ResponseInterface $ response ) { return $ this -> deserialize ( $ response -> getBody ( ) , $ this -> dataService -> getClass ( ) ) ; } ) ; return $ response ; }
|
Load an object from mpx .
|
56,313
|
public function select ( ObjectListQuery $ objectListQuery = null , array $ options = [ ] ) : ObjectListIterator { return new ObjectListIterator ( $ this -> selectRequest ( $ objectListQuery , $ options ) ) ; }
|
Query for MPX data using with parameters .
|
56,314
|
public function selectRequest ( ObjectListQuery $ objectListQuery = null , array $ options = [ ] ) : PromiseInterface { if ( ! $ objectListQuery ) { $ objectListQuery = new ObjectListQuery ( ) ; } $ annotation = $ this -> dataService -> getAnnotation ( ) ; if ( ! isset ( $ options [ 'query' ] ) ) { $ options [ 'query' ] = [ ] ; } $ options [ 'query' ] = $ options [ 'query' ] + $ objectListQuery -> toQueryParts ( ) + [ 'schema' => $ annotation -> schemaVersion , 'form' => 'cjson' , 'count' => true , ] ; if ( $ this -> authenticatedClient -> hasAccount ( ) ) { $ options [ 'query' ] [ 'account' ] = ( string ) $ this -> authenticatedClient -> getAccount ( ) -> getMpxId ( ) ; } $ uri = $ this -> getBaseUri ( $ annotation , true ) ; $ request = $ this -> authenticatedClient -> requestAsync ( 'GET' , $ uri , $ options ) -> then ( function ( ResponseInterface $ response ) use ( $ objectListQuery ) { return $ this -> deserializeObjectList ( $ response , $ objectListQuery ) ; } ) ; return $ request ; }
|
Return a promise to an object list .
|
56,315
|
private function deserializeObjectList ( ResponseInterface $ response , ObjectListQuery $ byFields ) : ObjectList { $ data = $ response -> getBody ( ) ; $ list = $ this -> deserialize ( $ data , ObjectList :: class ) ; $ decoded = \ GuzzleHttp \ json_decode ( $ data , true ) ; foreach ( $ list as $ index => $ item ) { $ entry = $ decoded [ 'entries' ] [ $ index ] ; if ( isset ( $ decoded [ '$xmlns' ] ) ) { $ entry [ '$xmlns' ] = $ decoded [ '$xmlns' ] ; } $ item -> setJson ( \ GuzzleHttp \ json_encode ( $ entry ) ) ; } $ list -> setObjectListQuery ( $ byFields ) ; $ list -> setDataObjectFactory ( $ this ) ; return $ list ; }
|
Deserialize an object list response .
|
56,316
|
private function getBaseUri ( DataService $ annotation , bool $ readonly = false ) : string { if ( ! ( $ base = $ annotation -> getBaseUri ( ) ) ) { if ( ! $ this -> authenticatedClient -> hasAccount ( ) ) { $ resolver = new ResolveAllUrls ( $ this -> authenticatedClient , $ this -> cacheItemPool ) ; return $ resolver -> resolve ( $ annotation -> getService ( $ readonly ) ) -> getUrl ( ) . $ annotation -> getPath ( ) ; } $ resolved = $ this -> resolveDomain -> resolve ( $ this -> authenticatedClient -> getAccount ( ) ) ; $ base = $ resolved -> getUrl ( $ annotation -> getService ( $ readonly ) ) . $ annotation -> getPath ( ) ; } return $ base ; }
|
Get the base URI from an annotation or service registry .
|
56,317
|
public static function fromResponseData ( array $ data ) : self { static :: validateData ( $ data ) ; $ lifetime = ( int ) floor ( min ( $ data [ 'signInResponse' ] [ 'duration' ] , $ data [ 'signInResponse' ] [ 'idleTimeout' ] ) / 1000 ) ; $ token = new self ( $ data [ 'signInResponse' ] [ 'userId' ] , $ data [ 'signInResponse' ] [ 'token' ] , $ lifetime ) ; return $ token ; }
|
Create a token from an MPX signInResponse .
|
56,318
|
public static function getConstants ( $ html = false ) { $ result = [ ] ; foreach ( ( new \ ReflectionClass ( get_class ( ) ) ) -> getConstants ( ) as $ constant ) { $ key = static :: $ cssPrefix . ' ' . static :: $ cssPrefix . '-' . $ constant ; $ result [ $ key ] = ( $ html ) ? static :: icon ( $ constant ) . ' ' . $ constant : $ constant ; } return $ result ; }
|
Get all icon constants for dropdown list in example
|
56,319
|
public function generateCore ( $ config , $ bar ) { $ this -> crudGenerator -> createModel ( $ config ) ; $ this -> crudGenerator -> createService ( $ config ) ; if ( strtolower ( $ config [ 'framework' ] ) === 'laravel' ) { $ this -> crudGenerator -> createRequest ( $ config ) ; } $ bar -> advance ( ) ; }
|
Generate core elements .
|
56,320
|
public function generateAppBased ( $ config , $ bar ) { if ( ! $ config [ 'options-serviceOnly' ] && ! $ config [ 'options-apiOnly' ] ) { $ this -> crudGenerator -> createController ( $ config ) ; $ this -> crudGenerator -> createViews ( $ config ) ; $ this -> crudGenerator -> createRoutes ( $ config ) ; if ( $ config [ 'options-withFacade' ] ) { $ this -> crudGenerator -> createFacade ( $ config ) ; } } $ bar -> advance ( ) ; }
|
Generate app based elements .
|
56,321
|
public function generateDB ( $ config , $ bar , $ section , $ table , $ splitTable , $ command ) { if ( $ config [ 'options-migration' ] ) { $ this -> dbGenerator -> createMigration ( $ config , $ section , $ table , $ splitTable , $ command ) ; if ( $ config [ 'options-schema' ] ) { $ this -> dbGenerator -> createSchema ( $ config , $ section , $ table , $ splitTable , $ config [ 'options-schema' ] ) ; } } $ bar -> advance ( ) ; }
|
Generate db elements .
|
56,322
|
public function generateAPI ( $ config , $ bar ) { if ( $ config [ 'options-api' ] || $ config [ 'options-apiOnly' ] ) { $ this -> crudGenerator -> createApi ( $ config ) ; } $ bar -> advance ( ) ; }
|
Generate api elements .
|
56,323
|
public function correctViewNamespace ( $ config ) { $ controllerFile = $ config [ '_path_controller_' ] . '/' . $ config [ '_ucCamel_casePlural_' ] . 'Controller.php' ; $ controller = file_get_contents ( $ controllerFile ) ; $ controller = str_replace ( "view('" . $ config [ '_sectionPrefix_' ] . $ config [ '_lower_casePlural_' ] . "." , "view('" . $ config [ '_sectionPrefix_' ] . $ config [ '_lower_casePlural_' ] . "::" , $ controller ) ; file_put_contents ( $ controllerFile , $ controller ) ; }
|
Corrects the namespace for the view .
|
56,324
|
public function acquireToken ( int $ duration = null , bool $ reset = false ) : Token { if ( $ reset ) { $ this -> tokenCachePool -> deleteToken ( $ this ) ; } try { $ token = $ this -> tokenCachePool -> getToken ( $ this ) ; } catch ( TokenNotFoundException $ e ) { $ token = $ this -> signInWithLock ( $ duration ) ; } return $ token ; }
|
Get a current authentication token for the account .
|
56,325
|
protected function signIn ( $ duration = null ) : Token { $ options = $ this -> signInOptions ( $ duration ) ; $ response = $ this -> client -> request ( 'GET' , self :: SIGN_IN_URL , $ options ) ; $ data = \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) , true ) ; $ token = $ this -> tokenFromResponse ( $ data ) ; $ this -> logger -> info ( 'Retrieved a new mpx token {token} for user {username} that expires on {date}.' , [ 'token' => $ token -> getValue ( ) , 'username' => $ this -> user -> getMpxUsername ( ) , 'date' => date ( DATE_ISO8601 , $ token -> getExpiration ( ) ) , ] ) ; return $ token ; }
|
Sign in the user and return the current token .
|
56,326
|
public function signOut ( ) { $ this -> client -> request ( 'GET' , self :: SIGN_OUT_URL , [ 'query' => [ 'schema' => '1.0' , 'form' => 'json' , '_token' => ( string ) $ this -> tokenCachePool -> getToken ( $ this ) , ] , ] ) ; $ this -> tokenCachePool -> deleteToken ( $ this ) ; }
|
Sign out the user .
|
56,327
|
protected function signInWithLock ( int $ duration = null ) : Token { if ( $ this -> store ) { $ factory = new Factory ( $ this -> store ) ; $ factory -> setLogger ( $ this -> logger ) ; $ lock = $ factory -> createLock ( $ this -> user -> getMpxUsername ( ) , 10 ) ; $ lock -> acquire ( true ) ; } try { $ token = $ this -> tokenCachePool -> getToken ( $ this ) ; } catch ( TokenNotFoundException $ e ) { $ token = $ this -> signIn ( $ duration ) ; } return $ token ; }
|
Sign in to mpx with a lock to prevent sign - in stampedes .
|
56,328
|
private function tokenFromResponse ( array $ data ) : Token { $ token = Token :: fromResponseData ( $ data ) ; $ this -> tokenCachePool -> setToken ( $ this , $ token ) ; return $ token ; }
|
Instantiate and cache a token .
|
56,329
|
private function signInOptions ( $ duration = null ) : array { $ options = [ ] ; $ options [ 'auth' ] = [ $ this -> user -> getMpxUsername ( ) , $ this -> user -> getMpxPassword ( ) , ] ; $ options [ 'query' ] = [ 'schema' => '1.0' , 'form' => 'json' , ] ; if ( ! empty ( $ duration ) ) { $ options [ 'query' ] [ '_duration' ] = $ duration * 1000 ; $ options [ 'query' ] [ '_idleTimeout' ] = $ duration * 1000 ; } return $ options ; }
|
Return the query parameters for signing in .
|
56,330
|
private function discoverCustomFields ( ) { $ path = $ this -> rootDir . '/' . $ this -> directory ; $ finder = new Finder ( ) ; $ finder -> files ( ) -> in ( $ path ) ; foreach ( $ finder as $ file ) { $ class = $ this -> classForFile ( $ file ) ; $ this -> registerAnnotation ( $ class ) ; } }
|
Discovers custom fields .
|
56,331
|
private function classForFile ( SplFileInfo $ file ) : string { $ subnamespace = str_replace ( '/' , '\\' , $ file -> getRelativePath ( ) ) ; if ( ! empty ( $ subnamespace ) ) { $ subnamespace .= '\\' ; } $ class = $ this -> namespace . '\\' . $ subnamespace . $ file -> getBasename ( '.php' ) ; return $ class ; }
|
Given a file path return the PSR - 4 class it should contain .
|
56,332
|
private function registerAnnotation ( $ class ) { if ( $ annotation = $ this -> annotationReader -> getClassAnnotation ( new \ ReflectionClass ( $ class ) , 'Lullabot\Mpx\DataService\Annotation\CustomField' ) ) { if ( ! is_subclass_of ( $ class , CustomFieldInterface :: class ) ) { throw new \ RuntimeException ( sprintf ( '%s must implement %s.' , $ class , CustomFieldInterface :: class ) ) ; } $ this -> customFields [ $ annotation -> service ] [ $ annotation -> objectType ] [ $ annotation -> namespace ] = new DiscoveredCustomField ( $ class , $ annotation ) ; } }
|
Register an annotation and it s custom fields .
|
56,333
|
public function sync ( ) { $ query = [ 'clientId' => $ this -> clientId , 'form' => 'cjson' , 'schema' => '1.10' , ] ; if ( $ this -> authenticatedClient -> hasAccount ( ) ) { $ query [ 'account' ] = ( string ) $ this -> authenticatedClient -> getAccount ( ) -> getMpxId ( ) ; } return $ this -> authenticatedClient -> requestAsync ( 'GET' , $ this -> uri , [ 'query' => $ query , ] ) -> then ( function ( ResponseInterface $ response ) { $ data = \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) , true ) ; return $ data [ 0 ] [ 'id' ] ; } ) ; }
|
Return the last available sync ID to synchronize notifications .
|
56,334
|
public function listen ( int $ since , int $ maximum = 500 ) { $ query = [ 'clientId' => $ this -> clientId , 'since' => $ since , 'block' => 'true' , 'form' => 'cjson' , 'schema' => '1.10' , 'filter' => $ this -> service -> getAnnotation ( ) -> getObjectType ( ) , 'size' => $ maximum , ] ; if ( $ this -> authenticatedClient -> hasAccount ( ) ) { $ query [ 'account' ] = ( string ) $ this -> authenticatedClient -> getAccount ( ) -> getMpxId ( ) ; } return $ this -> authenticatedClient -> requestAsync ( 'GET' , $ this -> uri , [ 'query' => $ query , ] ) -> then ( function ( ResponseInterface $ response ) { return $ this -> deserializeResponse ( $ response ) ; } ) ; }
|
Listen for notifications .
|
56,335
|
protected function deserializeResponse ( ResponseInterface $ response ) { $ encoders = [ new JsonEncoder ( ) ] ; $ extractor = new NotificationTypeExtractor ( ) ; $ extractor -> setClass ( $ this -> service -> getClass ( ) ) ; $ normalizers = [ new UnixMillisecondNormalizer ( ) , new UriNormalizer ( ) , new ObjectNormalizer ( null , null , null , $ extractor ) , new ArrayDenormalizer ( ) , ] ; $ serializer = new Serializer ( $ normalizers , $ encoders ) ; return $ serializer -> deserialize ( $ response -> getBody ( ) , Notification :: class . '[]' , 'json' ) ; }
|
Deserialize a notification response .
|
56,336
|
public function addSort ( string $ field , $ descending = false ) : self { $ this -> fields [ $ field ] = $ field . ( $ descending ? '|desc' : '' ) ; return $ this ; }
|
Add a sort to this query .
|
56,337
|
public function setFeedType ( ? SubFeed $ subFeed ) : void { if ( $ subFeed && ! $ subFeed -> getFeedType ( ) ) { throw new \ InvalidArgumentException ( 'The feedType field must be specified on the subfeed.' ) ; } $ this -> feedTypeSubFeed = $ subFeed ; }
|
Specifies a subfeed of the main feed .
|
56,338
|
protected function appendSeoTerms ( UriInterface $ uri ) : UriInterface { if ( ! empty ( $ this -> seoTerms ) ) { $ uri = $ uri -> withPath ( $ uri -> getPath ( ) . '/' . implode ( '/' , $ this -> seoTerms ) ) ; } return $ uri ; }
|
Append the SEO terms to the end of a URI .
|
56,339
|
public function compile ( $ outputfile ) { if ( empty ( $ this -> index ) ) { throw new \ LogicException ( 'Cannot compile when no index files are defined.' ) ; } if ( file_exists ( $ outputfile ) ) { unlink ( $ outputfile ) ; } $ name = basename ( $ outputfile ) ; $ phar = new \ Phar ( $ outputfile , 0 , $ name ) ; $ phar -> setSignatureAlgorithm ( \ Phar :: SHA1 ) ; $ phar -> startBuffering ( ) ; foreach ( $ this -> files as $ virtualfile => $ fileinfo ) { list ( $ realfile , $ strip ) = $ fileinfo ; $ content = file_get_contents ( $ realfile ) ; if ( $ strip ) { $ content = $ this -> stripWhitespace ( $ content ) ; } $ phar -> addFromString ( $ virtualfile , $ content ) ; } foreach ( $ this -> index as $ type => $ fileinfo ) { list ( $ virtualfile , $ realfile ) = $ fileinfo ; $ content = file_get_contents ( $ realfile ) ; if ( $ type == 'cli' ) { $ content = preg_replace ( '{^#!/usr/bin/env php\s*}' , '' , $ content ) ; } $ phar -> addFromString ( $ virtualfile , $ content ) ; } $ stub = $ this -> generateStub ( $ name ) ; $ phar -> setStub ( $ stub ) ; $ phar -> stopBuffering ( ) ; unset ( $ phar ) ; }
|
Compiles all files into a single PHAR file .
|
56,340
|
public function addFile ( $ file , $ strip = true ) { $ realfile = realpath ( $ this -> path . DIRECTORY_SEPARATOR . $ file ) ; $ this -> files [ $ file ] = [ $ realfile , ( bool ) $ strip ] ; }
|
Adds a file .
|
56,341
|
public function addDirectory ( $ directory , $ exclude = null , $ strip = true ) { $ realpath = realpath ( $ this -> path . DIRECTORY_SEPARATOR . $ directory ) ; $ iterator = new \ RecursiveDirectoryIterator ( $ realpath , \ FilesystemIterator :: SKIP_DOTS | \ FilesystemIterator :: UNIX_PATHS ) ; if ( ( is_string ( $ exclude ) || is_array ( $ exclude ) ) && ! empty ( $ exclude ) ) { $ iterator = new \ RecursiveCallbackFilterIterator ( $ iterator , function ( $ current ) use ( $ exclude , $ realpath ) { if ( $ current -> isDir ( ) ) { return true ; } $ subpath = substr ( $ current -> getPathName ( ) , strlen ( $ realpath ) + 1 ) ; return $ this -> filter ( $ subpath , ( array ) $ exclude ) ; } ) ; } $ iterator = new \ RecursiveIteratorIterator ( $ iterator ) ; foreach ( $ iterator as $ file ) { $ virtualfile = substr ( $ file -> getPathName ( ) , strlen ( $ this -> path ) + 1 ) ; $ this -> addFile ( $ virtualfile , $ strip ) ; } }
|
Adds files of the given directory recursively .
|
56,342
|
public function addIndexFile ( $ file , $ type = 'cli' ) { $ type = strtolower ( $ type ) ; if ( ! in_array ( $ type , [ 'cli' , 'web' ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Index file type "%s" is invalid, must be one of: cli, web' , $ type ) ) ; } $ this -> index [ $ type ] = [ $ file , realpath ( $ this -> path . DIRECTORY_SEPARATOR . $ file ) ] ; }
|
Adds an index file .
|
56,343
|
protected function filter ( $ path , array $ patterns ) { foreach ( $ patterns as $ pattern ) { if ( $ pattern [ 0 ] == '!' ? ! fnmatch ( substr ( $ pattern , 1 ) , $ path ) : fnmatch ( $ pattern , $ path ) ) { return false ; } } return true ; }
|
Filters the given path .
|
56,344
|
private function filterRequestParameters ( array $ httpRequest ) { if ( ! array_key_exists ( self :: DATA_FIELD , $ httpRequest ) || $ httpRequest [ self :: DATA_FIELD ] == '' ) { throw new InvalidArgumentException ( 'Data parameter not present in parameters.' ) ; } $ parameters = array ( ) ; $ dataString = $ httpRequest [ self :: DATA_FIELD ] ; $ this -> dataString = $ dataString ; $ dataParams = explode ( '|' , $ dataString ) ; foreach ( $ dataParams as $ dataParamString ) { $ dataKeyValue = explode ( '=' , $ dataParamString , 2 ) ; $ parameters [ $ dataKeyValue [ 0 ] ] = $ dataKeyValue [ 1 ] ; } return $ parameters ; }
|
Filter http request parameters
|
56,345
|
public function getParam ( $ key ) { if ( method_exists ( $ this , 'get' . $ key ) ) { return $ this -> { 'get' . $ key } ( ) ; } $ key = strtoupper ( $ key ) ; $ parameters = array_change_key_case ( $ this -> parameters , CASE_UPPER ) ; if ( ! array_key_exists ( $ key , $ parameters ) ) { throw new InvalidArgumentException ( 'Parameter ' . $ key . ' does not exist.' ) ; } return $ parameters [ $ key ] ; }
|
Retrieves a response parameter
|
56,346
|
public function setStartIndex ( int $ startIndex ) : self { if ( $ startIndex < 1 ) { throw new \ RangeException ( 'The start index must be 1 or greater.' ) ; } $ this -> startIndex = $ startIndex ; return $ this ; }
|
The start index of this range .
|
56,347
|
public static function nextRange ( ObjectList $ list ) : self { $ range = new self ( ) ; $ start = $ list -> getStartIndex ( ) + $ list -> getEntryCount ( ) ; $ range -> setStartIndex ( $ start ) -> setEndIndex ( $ start - 1 + $ list -> getItemsPerPage ( ) ) ; return $ range ; }
|
Given an object list return the range to load the next page of objects .
|
56,348
|
public static function nextRanges ( ObjectList $ list ) : array { $ ranges = [ ] ; $ endIndex = $ list -> getStartIndex ( ) + $ list -> getItemsPerPage ( ) - 1 ; $ finalEndIndex = $ list -> getTotalResults ( ) ; while ( $ endIndex < $ finalEndIndex ) { $ startIndex = ( $ startIndex ?? $ list -> getStartIndex ( ) ) + $ list -> getEntryCount ( ) ; $ endIndex = min ( $ startIndex + $ list -> getItemsPerPage ( ) - 1 , $ finalEndIndex ) ; $ range = new self ( ) ; $ range -> setStartIndex ( $ startIndex ) -> setEndIndex ( $ endIndex ) ; $ ranges [ ] = $ range ; } return $ ranges ; }
|
Given an object list return the ranges for each subsequent page .
|
56,349
|
public function toQueryParts ( ) : array { if ( empty ( $ this -> startIndex ) && empty ( $ this -> endIndex ) ) { return [ ] ; } if ( $ this -> endIndex - $ this -> startIndex > 250 ) { @ trigger_error ( 'PHP may leak memory with large result pages. Consider reducing the number of results per page.' , E_USER_DEPRECATED ) ; } return [ 'range' => $ this -> startIndex . '-' . $ this -> endIndex ] ; }
|
Return an array of query parameters representing this range .
|
56,350
|
public function renderItems ( ) { $ items = [ ] ; foreach ( $ this -> items as $ i => $ item ) { if ( isset ( $ item [ 'visible' ] ) && ! $ item [ 'visible' ] ) { continue ; } $ items [ ] = $ this -> renderItem ( $ item ) ; } $ hasActive = false ; foreach ( $ this -> items as $ i => $ child ) { if ( $ this -> isItemActive ( $ child ) ) { $ hasActive = true ; break ; } } if ( ! $ hasActive ) { Html :: addCssClass ( $ this -> options , 'collapse' ) ; } return Html :: tag ( 'ul' , implode ( "\n" , $ items ) , $ this -> options ) ; }
|
Customized widget for MetisMenu navigation dropdowns to not flicker on page load by precomputing if the menu should be open or not . Portions were added below to add the collapse css class if there is an item active within the submenu .
|
56,351
|
private function getDocBlockFromProperty ( $ class , $ property ) { try { $ reflectionProperty = new \ ReflectionProperty ( $ class , $ property ) ; } catch ( \ ReflectionException $ e ) { return ; } return $ this -> docBlockFactory -> create ( $ reflectionProperty , $ this -> contextFactory -> createFromReflector ( $ reflectionProperty -> getDeclaringClass ( ) ) ) ; }
|
Gets the DocBlock from a property .
|
56,352
|
public function toUri ( ) : UriInterface { $ str = $ this :: BASE_URL . $ this -> account -> getPid ( ) . '/' . $ this -> player -> getPid ( ) ; if ( $ this -> embed ) { $ str .= '/embed' ; } if ( $ this -> byGuid ) { $ ownerId = $ this -> media -> getOwnerId ( ) ; $ parts = explode ( '/' , $ ownerId ) ; $ numeric_id = end ( $ parts ) ; $ uri = new Uri ( $ str . '/select/media/guid/' . $ numeric_id . '/' . $ this -> media -> getGuid ( ) ) ; } else { $ uri = new Uri ( $ str . '/select/media/' . $ this -> media -> getPid ( ) ) ; } $ query_parts = [ ] ; if ( isset ( $ this -> autoPlay ) ) { $ query_parts [ 'autoPlay' ] = $ this -> autoPlay ? 'true' : 'false' ; } if ( isset ( $ this -> playAll ) ) { $ query_parts [ 'playAll' ] = $ this -> playAll ? 'true' : 'false' ; } $ uri = $ uri -> withQuery ( build_query ( $ query_parts ) ) ; return $ uri ; }
|
Return the URL for this player and media .
|
56,353
|
public function withAutoplay ( bool $ autoPlay ) : self { if ( $ this -> autoPlay == $ autoPlay ) { return $ this ; } $ url = clone $ this ; $ url -> autoPlay = $ autoPlay ; return $ url ; }
|
Override the player s autoplay setting for this URL .
|
56,354
|
public function withPlayAll ( bool $ playAll ) : self { if ( $ this -> playAll == $ playAll ) { return $ this ; } $ url = clone $ this ; $ url -> playAll = $ playAll ; return $ url ; }
|
Override the player s playAll setting for playlist auto - advance for this URL .
|
56,355
|
public function withMediaByGuid ( ) : self { if ( $ this -> byGuid ) { return $ this ; } $ url = clone $ this ; $ url -> byGuid = true ; return $ url ; }
|
Return a Url using media reference GUIDs instead of media public IDs .
|
56,356
|
public function withMediaByPublicId ( ) : self { if ( ! $ this -> byGuid ) { return $ this ; } $ url = clone $ this ; $ url -> byGuid = false ; return $ url ; }
|
Return a Url using media public IDs instead of media reference Ids .
|
56,357
|
public function getAdPolicyId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> adPolicyId ) { return new Uri ( ) ; } return $ this -> adPolicyId ; }
|
Returns the id of the AdPolicy object this object is associated with .
|
56,358
|
public function getFileId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> fileId ) { return new Uri ( ) ; } return $ this -> fileId ; }
|
Returns the id of the MediaFile object this object is associated with .
|
56,359
|
public function getRestrictionId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> restrictionId ) { return new Uri ( ) ; } return $ this -> restrictionId ; }
|
Returns the id of the Restriction object this object is associated with .
|
56,360
|
public function getUrl ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> url ) { return new Uri ( ) ; } return $ this -> url ; }
|
Returns the public URL for this object .
|
56,361
|
public function getDataService ( string $ name , string $ objectType , string $ schema ) { $ services = $ this -> discovery -> getDataServices ( ) ; if ( isset ( $ services [ $ name ] [ $ objectType ] [ $ schema ] ) ) { return $ services [ $ name ] [ $ objectType ] [ $ schema ] ; } throw new \ RuntimeException ( 'Data service not found.' ) ; }
|
Returns one data service by service .
|
56,362
|
private function renderField ( string $ value ) : string { if ( isset ( $ this -> field ) ) { $ field = '' ; if ( isset ( $ this -> namespace ) ) { $ field = $ this -> namespace . '$' ; } $ field .= $ this -> field ; if ( isset ( $ this -> matchType ) ) { $ field .= '.' . $ this -> matchType ; } $ value .= $ field . ':' ; } return $ value ; }
|
Add the field specification to the term string .
|
56,363
|
public function prepareTableDefinition ( $ table ) { $ tableDefintion = '' ; $ definitions = $ this -> calibrateDefinitions ( $ table ) ; foreach ( $ definitions as $ column ) { $ columnDefinition = explode ( ':' , $ column ) ; $ tableDefintion .= "\t\t'$columnDefinition[0]',\n" ; } return $ tableDefintion ; }
|
Prepare a string of the table .
|
56,364
|
public function prepareTableExample ( $ table ) { $ tableExample = '' ; $ definitions = $ this -> calibrateDefinitions ( $ table ) ; foreach ( $ definitions as $ key => $ column ) { $ columnDefinition = explode ( ':' , $ column ) ; $ example = $ this -> createExampleByType ( $ columnDefinition [ 1 ] ) ; if ( $ key === 0 ) { $ tableExample .= "'$columnDefinition[0]' => '$example',\n" ; } else { $ tableExample .= "\t\t'$columnDefinition[0]' => '$example',\n" ; } } return $ tableExample ; }
|
Prepare a table array example .
|
56,365
|
public function getTableSchema ( $ config , $ string ) { if ( ! empty ( $ config [ 'schema' ] ) ) { $ string = str_replace ( '// _camel_case_ table data' , $ this -> prepareTableExample ( $ config [ 'schema' ] ) , $ string ) ; } return $ string ; }
|
Build a table schema .
|
56,366
|
public function createExampleByType ( $ type ) { $ faker = Faker :: create ( ) ; $ typeArray = [ 'bigIncrements' => 1 , 'increments' => 1 , 'string' => $ faker -> word , 'boolean' => 1 , 'binary' => implode ( " " , $ faker -> words ( 10 ) ) , 'char' => 'a' , 'ipAddress' => '192.168.1.1' , 'macAddress' => 'X1:X2:X3:X4:X5:X6' , 'json' => json_encode ( [ 'json' => 'test' ] ) , 'text' => implode ( " " , $ faker -> words ( 4 ) ) , 'longText' => implode ( " " , $ faker -> sentences ( 4 ) ) , 'mediumText' => implode ( " " , $ faker -> sentences ( 2 ) ) , 'dateTime' => date ( 'Y-m-d h:i:s' ) , 'date' => date ( 'Y-m-d' ) , 'time' => date ( 'h:i:s' ) , 'timestamp' => time ( ) , 'float' => 1.1 , 'decimal' => 1.1 , 'double' => 1.1 , 'integer' => 1 , 'bigInteger' => 1 , 'mediumInteger' => 1 , 'smallInteger' => 1 , 'tinyInteger' => 1 , ] ; if ( isset ( $ typeArray [ $ type ] ) ) { return $ typeArray [ $ type ] ; } return 1 ; }
|
Create an example by type for table definitions .
|
56,367
|
public function tableDefintion ( $ table ) { $ columnStringArray = [ ] ; $ columns = $ this -> getTableColumns ( $ table , true ) ; foreach ( $ columns as $ key => $ column ) { if ( $ key === 'id' ) { $ column [ 'type' ] = 'increments' ; } $ columnStringArray [ ] = $ key . ':' . $ this -> columnNameCheck ( $ column [ 'type' ] ) ; } $ columnString = implode ( ',' , $ columnStringArray ) ; return $ columnString ; }
|
Table definitions .
|
56,368
|
public function getTableColumns ( $ table , $ allColumns = false ) { $ tableColumns = Schema :: getColumnListing ( $ table ) ; $ tableTypeColumns = [ ] ; $ badColumns = [ 'id' , 'created_at' , 'updated_at' ] ; if ( $ allColumns ) { $ badColumns = [ ] ; } foreach ( $ tableColumns as $ column ) { if ( ! in_array ( $ column , $ badColumns ) ) { $ type = DB :: connection ( ) -> getDoctrineColumn ( $ table , $ column ) -> getType ( ) -> getName ( ) ; $ tableTypeColumns [ $ column ] [ 'type' ] = $ type ; } } return $ tableTypeColumns ; }
|
Get Table Columns .
|
56,369
|
private function discoverDataServices ( ) { $ path = $ this -> rootDir . '/' . $ this -> directory ; $ finder = new Finder ( ) ; $ finder -> files ( ) -> in ( $ path ) ; foreach ( $ finder as $ file ) { $ class = $ this -> classForFile ( $ file ) ; $ annotation = $ this -> annotationReader -> getClassAnnotation ( new \ ReflectionClass ( $ class ) , 'Lullabot\Mpx\DataService\Annotation\DataService' ) ; if ( ! $ annotation ) { continue ; } $ customFields = $ this -> getCustomFields ( $ annotation ) ; $ this -> dataServices [ $ annotation -> getService ( ) ] [ $ annotation -> getObjectType ( ) ] [ $ annotation -> getSchemaVersion ( ) ] = new DiscoveredDataService ( $ class , $ annotation , $ customFields ) ; } }
|
Discovers data services .
|
56,370
|
private function getCustomFields ( DataService $ annotation ) : array { $ fields = $ this -> customFieldManager -> getCustomFields ( ) ; $ customFields = [ ] ; if ( isset ( $ fields [ $ annotation -> getService ( ) ] [ $ annotation -> getObjectType ( ) ] ) ) { $ customFields = $ fields [ $ annotation -> getService ( ) ] [ $ annotation -> getObjectType ( ) ] ; } return $ customFields ; }
|
Return the array of custom fields for an annotation .
|
56,371
|
public function getUrl ( bool $ insecure = false ) : UriInterface { $ url = $ this -> resolveAllUrlsResponse [ array_rand ( $ this -> resolveAllUrlsResponse ) ] ; if ( $ insecure ) { return $ url ; } return $ url -> withScheme ( 'https' ) ; }
|
Return the resolved URL for this service .
|
56,372
|
public function searchRegion ( $ region , $ term , $ params = array ( ) ) { return $ this -> search ( $ term , array_merge ( array ( 'country' => strtoupper ( $ region ) ) , $ params ) ) ; }
|
Search withing a defined region .
|
56,373
|
public function request ( $ type , $ params = array ( ) ) { if ( isset ( $ this -> iTunesConfig [ 'api' ] ) ) { if ( isset ( $ this -> iTunesConfig [ 'api' ] [ 'url' ] ) && isset ( $ this -> iTunesConfig [ 'api' ] [ 'search_uri' ] ) && isset ( $ this -> iTunesConfig [ 'api' ] [ 'lookup_uri' ] ) ) { $ host = $ this -> iTunesConfig [ 'api' ] [ 'url' ] ; switch ( $ type ) { case 'search' : default : $ uri = $ this -> iTunesConfig [ 'api' ] [ 'search_uri' ] ; $ params = array_merge ( array ( 'limit' => isset ( $ this -> iTunesConfig [ 'limit' ] ) ? $ this -> iTunesConfig [ 'limit' ] : 50 , ) , $ params ) ; break ; case 'lookup' : $ uri = $ this -> iTunesConfig [ 'api' ] [ 'lookup_uri' ] ; break ; } return array ( 'url' => $ host . $ uri , 'params' => $ params , ) ; } } throw new ConfigurationException ( 'Incomplete Configuration' ) ; }
|
Builds up the request array .
|
56,374
|
protected function getLookupParams ( $ id , $ value , array $ params ) { if ( ! $ value ) { $ value = $ id ; $ id = 'id' ; } return array_merge ( array ( $ id => $ value ) , $ params ) ; }
|
Get the query params for a lookup request .
|
56,375
|
public function resolve ( IdInterface $ account ) : ResolveDomainResponse { $ key = md5 ( $ account -> getMpxId ( ) . static :: SCHEMA_VERSION ) ; $ item = $ this -> cache -> getItem ( $ key ) ; if ( $ item -> isHit ( ) ) { return $ item -> get ( ) ; } $ options = [ 'query' => [ 'schema' => static :: SCHEMA_VERSION , '_accountId' => ( string ) $ account -> getMpxId ( ) , 'account' => ( string ) $ account -> getMpxId ( ) , ] , ] ; $ response = $ this -> authenticatedClient -> request ( 'GET' , static :: RESOLVE_DOMAIN_URL , $ options ) ; $ encoders = [ new JsonEncoder ( ) ] ; $ normalizers = [ new UriNormalizer ( ) , new ObjectNormalizer ( null , null , null , new ResolveDomainResponseExtractor ( ) ) , new ArrayDenormalizer ( ) ] ; $ serializer = new Serializer ( $ normalizers , $ encoders ) ; $ resolved = $ serializer -> deserialize ( $ response -> getBody ( ) , ResolveDomainResponse :: class , 'json' ) ; $ item -> set ( $ resolved ) ; $ item -> expiresAfter ( new \ DateInterval ( 'P30D' ) ) ; $ this -> cache -> save ( $ item ) ; return $ resolved ; }
|
Resolve all URLs for an account .
|
56,376
|
public function setToken ( UserSession $ user , Token $ token ) { $ item = $ this -> cacheItemPool -> getItem ( $ this -> cacheKey ( $ user ) ) ; $ item -> set ( $ token ) ; $ item -> expiresAfter ( $ token -> getLifetime ( ) ) ; $ this -> cacheItemPool -> save ( $ item ) ; }
|
Set an authentication token for a user .
|
56,377
|
public function getToken ( UserSession $ user ) : Token { $ item = $ this -> cacheItemPool -> getItem ( $ this -> cacheKey ( $ user ) ) ; if ( ! $ item -> isHit ( ) ) { throw new TokenNotFoundException ( $ user ) ; } return $ item -> get ( ) ; }
|
Get the cached token for a user .
|
56,378
|
public function title ( $ value = null ) { $ this -> options = array_merge ( $ this -> options , [ 'title' => ( $ value == null ? $ this -> name : $ value ) ] ) ; return $ this ; }
|
Adds title attribute
|
56,379
|
public function id ( $ value = null ) { $ this -> options = array_merge ( $ this -> options , [ 'id' => ( $ value == null ? $ this -> name : $ value ) ] ) ; return $ this ; }
|
Adds id attribute
|
56,380
|
public function prepareModelRelationships ( $ relationships ) { $ relationshipMethods = '' ; foreach ( $ relationships as $ relation ) { if ( ! isset ( $ relation [ 2 ] ) ) { $ relationEnd = explode ( '\\' , $ relation [ 1 ] ) ; $ relation [ 2 ] = strtolower ( end ( $ relationEnd ) ) ; } $ method = str_singular ( $ relation [ 2 ] ) ; if ( stristr ( $ relation [ 0 ] , 'many' ) ) { $ method = str_plural ( $ relation [ 2 ] ) ; } $ relationshipMethods .= "\n\tpublic function " . $ method . '() {' ; $ relationshipMethods .= "\n\t\treturn \$this->$relation[0]($relation[1]::class);" ; $ relationshipMethods .= "\n\t}\n\t" ; } return $ relationshipMethods ; }
|
Prepare a models relationships .
|
56,381
|
public function configTheModel ( $ config , $ model ) { if ( ! empty ( $ config [ 'schema' ] ) ) { $ model = str_replace ( '// _camel_case_ table data' , $ this -> tableService -> prepareTableDefinition ( $ config [ 'schema' ] ) , $ model ) ; } if ( ! empty ( $ config [ 'relationships' ] ) ) { $ relationships = [ ] ; foreach ( explode ( ',' , $ config [ 'relationships' ] ) as $ relationshipExpression ) { $ relationships [ ] = explode ( '|' , $ relationshipExpression ) ; } $ model = str_replace ( '// _camel_case_ relationships' , $ this -> prepareModelRelationships ( $ relationships ) , $ model ) ; } return $ model ; }
|
Configure the model .
|
56,382
|
private function mergeAuth ( array $ options , bool $ reset = false ) : array { if ( ! isset ( $ options [ 'query' ] ) ) { $ options [ 'query' ] = [ ] ; } $ token = $ this -> userSession -> acquireToken ( $ this -> duration , $ reset ) ; $ options [ 'query' ] += [ 'token' => $ token -> getValue ( ) , ] ; return $ options ; }
|
Merge authentication headers into request options .
|
56,383
|
private function finallyResolve ( PromiseInterface $ promise , callable $ callable , $ args ) { try { $ promise -> resolve ( \ call_user_func_array ( $ callable , $ args ) ) ; } catch ( \ Exception $ e ) { $ promise -> reject ( $ e ) ; } }
|
Resolve or reject a promise by invoking a callable .
|
56,384
|
private function outerPromise ( PromiseInterface $ inner ) : Promise { $ outer = new Promise ( function ( ) use ( $ inner ) { try { $ inner -> wait ( ) ; } catch ( \ Exception $ e ) { } } ) ; return $ outer ; }
|
Return a new promise that waits on another promise .
|
56,385
|
public function isAvailable ( Media $ media , \ DateTime $ time ) { return $ this -> between ( $ time , $ media -> getAvailableDate ( ) , $ media -> getExpirationDate ( ) ) ; }
|
Return if the media is available as of the given time .
|
56,386
|
private function between ( \ DateTime $ time , DateTimeFormatInterface $ start , DateTimeFormatInterface $ end ) { return $ this -> after ( $ time , $ start ) && $ this -> before ( $ time , $ end ) ; }
|
Return if a time is between a start and end time .
|
56,387
|
private function before ( \ DateTime $ time , DateTimeFormatInterface $ other ) { if ( $ other instanceof ConcreteDateTimeInterface ) { if ( $ this -> isEpoch ( $ other ) ) { return true ; } return $ time <= $ other -> getDateTime ( ) ; } return true ; }
|
Return if a time is equal to or before the other time .
|
56,388
|
public function createController ( $ config ) { $ this -> fileService -> mkdir ( $ config [ '_path_controller_' ] , 0777 , true ) ; $ request = $ this -> fileService -> get ( $ config [ 'template_source' ] . '/Controller.txt' ) ; foreach ( $ config as $ key => $ value ) { $ request = str_replace ( $ key , $ value , $ request ) ; } $ request = $ this -> putIfNotExists ( $ config [ '_path_controller_' ] . '/' . $ config [ '_ucCamel_casePlural_' ] . 'Controller.php' , $ request ) ; return $ request ; }
|
Create the controller .
|
56,389
|
public function createModel ( $ config ) { $ repoParts = [ '_path_model_' , ] ; foreach ( $ repoParts as $ repoPart ) { $ this -> fileService -> mkdir ( $ config [ $ repoPart ] , 0777 , true ) ; } $ model = $ this -> fileService -> get ( $ config [ 'template_source' ] . '/Model.txt' ) ; $ model = $ this -> modelService -> configTheModel ( $ config , $ model ) ; foreach ( $ config as $ key => $ value ) { $ model = str_replace ( $ key , $ value , $ model ) ; } $ model = $ this -> putIfNotExists ( $ config [ '_path_model_' ] . '/' . $ config [ '_camel_case_' ] . '.php' , $ model ) ; return $ model ; }
|
Create the model .
|
56,390
|
public function createService ( $ config ) { $ this -> fileService -> mkdir ( $ config [ '_path_service_' ] , 0777 , true ) ; $ service = $ this -> fileService -> get ( $ config [ 'template_source' ] . '/Service.txt' ) ; if ( $ config [ 'options-withBaseService' ] ?? false ) { $ baseService = $ this -> fileService -> get ( $ config [ 'template_source' ] . '/BaseService.txt' ) ; $ service = $ this -> fileService -> get ( $ config [ 'template_source' ] . '/ExtendedService.txt' ) ; } foreach ( $ config as $ key => $ value ) { $ service = str_replace ( $ key , $ value , $ service ) ; if ( $ config [ 'options-withBaseService' ] ?? false ) { $ baseService = str_replace ( $ key , $ value , $ baseService ) ; } } $ service = $ this -> putIfNotExists ( $ config [ '_path_service_' ] . '/' . $ config [ '_camel_case_' ] . 'Service.php' , $ service ) ; if ( $ config [ 'options-withBaseService' ] ?? false ) { $ this -> putIfNotExists ( $ config [ '_path_service_' ] . '/BaseService.php' , $ baseService ) ; } return $ service ; }
|
Create the service .
|
56,391
|
public function createFactory ( $ config ) { $ this -> fileService -> mkdir ( dirname ( $ config [ '_path_factory_' ] ) , 0777 , true ) ; if ( ! file_exists ( $ config [ '_path_factory_' ] ) ) { $ this -> putIfNotExists ( $ config [ '_path_factory_' ] , '<?php' ) ; } $ factory = $ this -> fileService -> get ( $ config [ 'template_source' ] . '/Factory.txt' ) ; $ factory = $ this -> tableService -> getTableSchema ( $ config , $ factory ) ; foreach ( $ config as $ key => $ value ) { $ factory = str_replace ( $ key , $ value , $ factory ) ; } return $ this -> filesystem -> append ( $ config [ '_path_factory_' ] , $ factory ) ; }
|
Append to the factory .
|
56,392
|
public function createFacade ( $ config ) { $ this -> fileService -> mkdir ( $ config [ '_path_facade_' ] , 0777 , true ) ; $ facade = $ this -> fileService -> get ( $ config [ 'template_source' ] . '/Facade.txt' ) ; foreach ( $ config as $ key => $ value ) { $ facade = str_replace ( $ key , $ value , $ facade ) ; } $ facade = $ this -> putIfNotExists ( $ config [ '_path_facade_' ] . '/' . $ config [ '_camel_case_' ] . '.php' , $ facade ) ; return $ facade ; }
|
Create the facade .
|
56,393
|
public function generatePackageServiceProvider ( $ config ) { $ provider = $ this -> fileService -> get ( __DIR__ . '/../Templates/Provider.txt' ) ; foreach ( $ config as $ key => $ value ) { $ provider = str_replace ( $ key , $ value , $ provider ) ; } $ provider = $ this -> putIfNotExists ( $ config [ '_path_package_' ] . '/' . $ config [ '_camel_case_' ] . 'ServiceProvider.php' , $ provider ) ; return $ provider ; }
|
Create a service provider .
|
56,394
|
public function createViews ( $ config ) { $ this -> fileService -> mkdir ( $ config [ '_path_views_' ] . '/' . $ config [ '_lower_casePlural_' ] , 0777 , true ) ; $ viewTemplates = 'Views' ; if ( $ config [ 'bootstrap' ] ) { $ viewTemplates = 'BootstrapViews' ; } if ( $ config [ 'semantic' ] ) { $ viewTemplates = 'SemanticViews' ; } $ createdView = false ; foreach ( glob ( $ config [ 'template_source' ] . '/' . $ viewTemplates . '/*' ) as $ file ) { $ viewContents = $ this -> fileService -> get ( $ file ) ; $ basename = str_replace ( 'txt' , 'php' , basename ( $ file ) ) ; foreach ( $ config as $ key => $ value ) { $ viewContents = str_replace ( $ key , $ value , $ viewContents ) ; } $ createdView = $ this -> putIfNotExists ( $ config [ '_path_views_' ] . '/' . $ config [ '_lower_casePlural_' ] . '/' . $ basename , $ viewContents ) ; } return $ createdView ; }
|
Create the views .
|
56,395
|
public function createApi ( $ config ) { $ routesMaster = $ config [ '_path_api_routes_' ] ; if ( ! file_exists ( $ routesMaster ) ) { $ this -> putIfNotExists ( $ routesMaster , "<?php\n\n" ) ; } $ this -> fileService -> mkdir ( $ config [ '_path_api_controller_' ] , 0777 , true ) ; $ routes = $ this -> fileService -> get ( $ config [ 'template_source' ] . '/ApiRoutes.txt' ) ; foreach ( $ config as $ key => $ value ) { $ routes = str_replace ( $ key , $ value , $ routes ) ; } $ this -> filesystem -> append ( $ routesMaster , $ routes ) ; $ request = $ this -> fileService -> get ( $ config [ 'template_source' ] . '/ApiController.txt' ) ; foreach ( $ config as $ key => $ value ) { $ request = str_replace ( $ key , $ value , $ request ) ; } $ request = $ this -> putIfNotExists ( $ config [ '_path_api_controller_' ] . '/' . $ config [ '_ucCamel_casePlural_' ] . 'Controller.php' , $ request ) ; return $ request ; }
|
Create the Api .
|
56,396
|
public function putIfNotExists ( $ file , $ contents ) { if ( ! $ this -> filesystem -> exists ( $ file ) ) { return $ this -> filesystem -> put ( $ file , $ contents ) ; } return $ this -> fileService -> get ( $ file ) ; }
|
Make a file if it doesnt exist .
|
56,397
|
public function createCRUD ( $ config , $ section , $ table , $ splitTable ) { $ bar = $ this -> output -> createProgressBar ( 7 ) ; try { $ this -> crudService -> generateCore ( $ config , $ bar ) ; $ this -> crudService -> generateAppBased ( $ config , $ bar ) ; $ this -> crudGenerator -> createTests ( $ config , $ this -> option ( 'serviceOnly' ) , $ this -> option ( 'apiOnly' ) , $ this -> option ( 'api' ) ) ; $ bar -> advance ( ) ; $ this -> crudGenerator -> createFactory ( $ config ) ; $ bar -> advance ( ) ; $ this -> crudService -> generateAPI ( $ config , $ bar ) ; $ bar -> advance ( ) ; $ this -> crudService -> generateDB ( $ config , $ bar , $ section , $ table , $ splitTable , $ this ) ; $ bar -> finish ( ) ; $ this -> crudReport ( $ table ) ; } catch ( Exception $ e ) { throw new Exception ( 'Unable to generate your CRUD: (' . $ e -> getFile ( ) . ':' . $ e -> getLine ( ) . ') ' . $ e -> getMessage ( ) , 1 ) ; } }
|
Create a CRUD .
|
56,398
|
private function crudReport ( $ table ) { $ this -> line ( "\n" ) ; $ this -> line ( 'Built model...' ) ; $ this -> line ( 'Built request...' ) ; $ this -> line ( 'Built service...' ) ; if ( ! $ this -> option ( 'serviceOnly' ) && ! $ this -> option ( 'apiOnly' ) ) { $ this -> line ( 'Built controller...' ) ; if ( ! $ this -> option ( 'withoutViews' ) ) { $ this -> line ( 'Built views...' ) ; } $ this -> line ( 'Built routes...' ) ; } if ( $ this -> option ( 'withFacade' ) ) { $ this -> line ( 'Built facade...' ) ; } $ this -> line ( 'Built tests...' ) ; $ this -> line ( 'Built factory...' ) ; if ( $ this -> option ( 'api' ) || $ this -> option ( 'apiOnly' ) ) { $ this -> line ( 'Built api...' ) ; $ this -> comment ( "\nAdd the following to your app/Providers/RouteServiceProvider.php: \n" ) ; $ this -> info ( "require base_path('routes/api.php'); \n" ) ; } if ( $ this -> option ( 'migration' ) ) { $ this -> line ( 'Built migration...' ) ; if ( $ this -> option ( 'schema' ) ) { $ this -> line ( 'Built schema...' ) ; } } else { $ this -> info ( "\nYou will want to create a migration in order to get the $table tests to work correctly.\n" ) ; } }
|
Generate a CRUD report .
|
56,399
|
public function getAvailableDate ( ) : \ Lullabot \ Mpx \ DataService \ DateTime \ DateTimeFormatInterface { if ( ! $ this -> availableDate ) { return new NullDateTime ( ) ; } return $ this -> availableDate ; }
|
Returns the date that this content becomes available for playback .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.