idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
23,500
protected function enqueue_fallback_handle ( $ handle ) { $ result = false ; foreach ( $ this -> handlers as $ handler ) { $ result = $ result || $ handler -> maybe_enqueue ( $ handle ) ; } return $ result ; }
Enqueue a single dependency from the WP - registered dependencies retrieved by its handle .
23,501
protected function enqueue_dependency_type ( $ dependencies , $ dependency_type , $ context = null ) { $ context [ 'dependency_type' ] = $ dependency_type ; array_walk ( $ dependencies , [ $ this , 'enqueue_dependency' ] , $ context ) ; }
Enqueue all dependencies of a specific type .
23,502
protected function register_dependency_type ( $ dependencies , $ dependency_type , $ context = null ) { $ context [ 'dependency_type' ] = $ dependency_type ; array_walk ( $ dependencies , [ $ this , 'register_dependency' ] , $ context ) ; }
Register all dependencies of a specific type .
23,503
protected function register_dependency ( $ dependency , $ dependency_key , $ context = null ) { $ handler = $ this -> handlers [ $ context [ 'dependency_type' ] ] ; $ handler -> register ( $ dependency ) ; if ( $ this -> enqueue_immediately ) { $ this -> register_enqueue_hooks ( $ dependency , $ context ) ; } }
Register a single dependency .
23,504
protected function register_enqueue_hooks ( $ dependency , $ context = null ) { $ priority = $ this -> get_priority ( $ dependency ) ; foreach ( [ 'wp_enqueue_scripts' , 'admin_enqueue_scripts' ] as $ hook ) { add_action ( $ hook , [ $ this , 'enqueue' ] , $ priority , 1 ) ; } $ this -> maybe_localize ( $ dependency , $ context ) ; $ this -> maybe_add_inline_script ( $ dependency , $ context ) ; }
Register the enqueueing to WordPress hooks .
23,505
public function updateElasticMappings ( $ mappings ) { $ mappings [ 'BoostTerms' ] = [ 'type' => 'keyword' ] ; $ mappings [ 'Categories' ] = [ 'type' => 'keyword' ] ; $ mappings [ 'Keywords' ] = [ 'type' => 'text' ] ; $ mappings [ 'Tags' ] = [ 'type' => 'keyword' ] ; if ( $ this -> owner instanceof \ SiteTree ) { $ mappings [ 'SS_URL' ] = [ 'type' => 'text' ] ; } }
Sets appropriate mappings for fields that need to be subsequently faceted upon
23,506
public function createFormErrorArray ( Form $ data ) { $ form = [ ] ; $ errors = [ ] ; foreach ( $ data -> getErrors ( ) as $ error ) { $ errors [ ] = $ this -> getErrorMessage ( $ error ) ; } if ( $ errors ) { $ form [ 'errors' ] = $ errors ; } $ children = [ ] ; foreach ( $ data -> all ( ) as $ child ) { if ( $ child instanceof Form ) { $ children [ $ child -> getName ( ) ] = $ this -> createFormErrorArray ( $ child ) ; } } if ( $ children ) { $ form [ 'children' ] = $ children ; } return $ form ; }
Recursively loops through the form object and returns an array of errors
23,507
protected function ssePolling ( $ data , $ eventId = 'stream' , $ retry = 1000 ) : Response { return ResponseFactory :: getInstance ( ) -> buildPollingSse ( $ data , $ eventId , $ retry ) ; }
Does a simple server - sent event response which will do a simple polling .
23,508
protected function sseStreaming ( $ callback , $ eventId = 'stream' , $ sleep = 1 ) : Response { return ResponseFactory :: getInstance ( ) -> buildStreamingSse ( $ callback , $ eventId , $ sleep ) ; }
Does a streaming server - sent event response which will loop and execute the specified callback indefinitely and update the client only when needed .
23,509
protected function materialDesignColorPalette ( $ type , $ name , $ value ) { $ color = $ this -> getColors ( ) [ 0 ] ; foreach ( $ this -> getColors ( ) as $ current ) { if ( $ name !== $ current -> getName ( ) ) { continue ; } $ color = $ current ; } $ html = [ ] ; $ html [ ] = "mdc" ; $ html [ ] = $ type ; $ html [ ] = $ color -> getName ( ) ; if ( null !== $ value && true === array_key_exists ( $ value , $ color -> getColors ( ) ) ) { $ html [ ] = $ value ; } return implode ( "-" , $ html ) ; }
Displays a Material Design Color Palette .
23,510
public function getTags ( ) { return implode ( "," , array_keys ( ArrayHelper :: map ( $ this -> owner -> getModelTags ( ) -> asArray ( ) -> all ( ) , 'name' , 'name' ) ) ) ; }
Get the tags separated by . It uses the relation called modelTags from the model
23,511
public function tagsRelationTable ( ) { $ model_name = $ this -> owner -> formName ( ) ; if ( $ model_name > 'Tag' ) { $ relationship_table = 'Tag_' . $ model_name ; } else { $ relationship_table = $ model_name . '_Tag' ; } return $ relationship_table ; }
Get the name of the relationship table
23,512
public function beginTransaction ( ) { if ( $ this -> currentTransactionLevel == 0 || ! $ this -> nestable ( ) ) { parent :: beginTransaction ( ) ; } else { $ this -> exec ( "SAVEPOINT LEVEL{$this->currentTransactionLevel}" ) ; } ++ $ this -> currentTransactionLevel ; return true ; }
PDO begin transaction override to work with savepoint capabilities for supported SGBD . Allows nested transactions .
23,513
public function commit ( ) { -- $ this -> currentTransactionLevel ; if ( $ this -> currentTransactionLevel == 0 || ! $ this -> nestable ( ) ) { parent :: commit ( ) ; } else { $ this -> exec ( "RELEASE SAVEPOINT LEVEL{$this->currentTransactionLevel}" ) ; } }
PDO commit override to work with savepoint capabilities for supported SGBD . Allows nested transactions .
23,514
public function rollBack ( ) { -- $ this -> currentTransactionLevel ; if ( $ this -> currentTransactionLevel == 0 || ! $ this -> nestable ( ) ) { parent :: rollBack ( ) ; } else { $ this -> exec ( "ROLLBACK TO SAVEPOINT LEVEL{$this->currentTransactionLevel}" ) ; } }
PDO rollback override to work with savepoint capabilities for supported SGBD . Allows nested transactions .
23,515
public function getSiteInfo ( $ siteId ) { $ queryBuilder = $ this -> _em -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'partial site.{ owner, theme, status, favIcon, loginPage, notAuthorizedPage, siteLayout, siteTitle, siteId }, language, country' ) -> from ( \ Rcm \ Entity \ Site :: class , 'site' ) -> join ( 'site.country' , 'country' ) -> join ( 'site.language' , 'language' ) -> where ( 'site.siteId = :siteId' ) -> setParameter ( 'siteId' , $ siteId ) ; try { return $ queryBuilder -> getQuery ( ) -> getSingleResult ( Query :: HYDRATE_ARRAY ) ; } catch ( NoResultException $ e ) { return null ; } }
Get Site Info
23,516
public function getSites ( $ mustBeActive = false ) { $ repo = $ this -> _em -> getRepository ( \ Rcm \ Entity \ Site :: class ) ; if ( $ mustBeActive ) { return $ repo -> findBy ( [ 'status' => \ Rcm \ Entity \ Site :: STATUS_ACTIVE ] ) ; } else { return $ repo -> findAll ( ) ; } }
Get All Active Site Objects
23,517
public function isValidSiteId ( $ siteId , $ checkActive = false ) { if ( empty ( $ siteId ) || ! is_numeric ( $ siteId ) ) { return false ; } if ( $ checkActive && in_array ( $ siteId , $ this -> activeSiteIdCache ) ) { return true ; } $ queryBuilder = $ this -> _em -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'site.siteId' ) -> from ( \ Rcm \ Entity \ Site :: class , 'site' ) -> where ( 'site.siteId = :siteId' ) -> setParameter ( 'siteId' , $ siteId ) ; if ( $ checkActive ) { $ queryBuilder -> andWhere ( 'site.status = :status' ) ; $ queryBuilder -> setParameter ( 'status' , \ Rcm \ Entity \ Site :: STATUS_ACTIVE ) ; } $ result = $ queryBuilder -> getQuery ( ) -> getScalarResult ( ) ; if ( ! empty ( $ result ) ) { if ( $ checkActive ) { $ this -> activeSiteIdCache [ ] = $ siteId ; } return true ; } return false ; }
Is Valid Site Id
23,518
public function getSiteByDomain ( $ domain ) { $ queryBuilder = $ this -> _em -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'domain, site, primaryDomain' ) -> from ( \ Rcm \ Entity \ Domain :: class , 'domain' ) -> leftJoin ( 'domain.site' , 'site' ) -> leftJoin ( 'domain.primaryDomain' , 'primaryDomain' ) -> where ( 'domain.domain = :domainName' ) -> setParameter ( 'domainName' , $ domain ) ; try { $ domain = $ queryBuilder -> getQuery ( ) -> getSingleResult ( ) ; } catch ( NoResultException $ e ) { return null ; } if ( $ domain -> getPrimary ( ) ) { $ site = $ domain -> getPrimary ( ) -> getSite ( ) ; $ this -> _em -> detach ( $ site ) ; $ this -> _em -> detach ( $ domain ) ; $ site -> setDomain ( $ domain ) ; } else { $ site = $ domain -> getSite ( ) ; } return $ site ; }
Gets site from db by domain name
23,519
protected function getPrimaryDomain ( $ domain ) { $ domain = $ this -> _em -> getRepository ( \ Rcm \ Entity \ Domain :: class ) -> findOneBy ( [ 'domain' => $ domain ] ) ; if ( empty ( $ domain ) ) { return null ; } $ primary = $ domain -> getPrimary ( ) ; if ( ! $ primary -> getPrimary ( ) ) { return $ primary ; } return $ this -> getPrimaryDomain ( $ primary -> getDomainName ( ) ) ; }
Get the Primary Domain for site lookup
23,520
public function getDashboard ( ) { $ view = 'admin.dashboard' ; if ( ! view ( ) -> exists ( $ view ) ) { $ view = 'flare::' . $ view ; } return view ( $ view , [ 'widgets' => ( new WidgetAdminManager ( ) ) ] ) ; }
Show the Dashboard .
23,521
protected function fullTextWildcards ( $ term ) { $ reservedSymbols = [ '-' , '+' , '<' , '>' , '@' , '(' , ')' , '~' ] ; $ term = str_replace ( $ reservedSymbols , '' , $ term ) ; $ words = explode ( ' ' , $ term ) ; foreach ( $ words as $ key => $ word ) { if ( strlen ( $ word ) >= 3 ) { $ words [ $ key ] = $ word . '*' ; } } $ searchTerm = implode ( ' ' , $ words ) ; return $ searchTerm ; }
Replaces spaces with full text search wildcards
23,522
public function scopeSearch ( $ query , $ term ) { $ columns = implode ( ',' , $ this -> searchable ) ; $ query -> whereRaw ( "MATCH ({$columns}) AGAINST (? IN BOOLEAN MODE)" , $ this -> fullTextWildcards ( $ term ) ) ; return $ query ; }
Scope a query that matches a full text search of term .
23,523
public function process ( ContainerBuilder $ container ) { if ( ! $ container -> has ( $ this -> serviceId ) ) { return ; } $ definition = $ container -> findDefinition ( $ this -> serviceId ) ; $ handlers = array ( ) ; $ this -> collectServiceIds ( $ container , $ this -> tag , $ this -> keyAttribute , function ( $ key , $ serviceId , array $ tagAttributes ) use ( & $ handlers ) { if ( isset ( $ tagAttributes [ 'method' ] ) ) { $ callable = [ $ serviceId , $ tagAttributes [ 'method' ] ] ; } else { $ callable = $ serviceId ; } $ handlers [ ltrim ( $ key , '\\' ) ] = $ callable ; } ) ; $ definition -> replaceArgument ( 0 , $ handlers ) ; }
Search for message handler services and provide them as a constructor argument to the message handler map service .
23,524
public function writeAsync ( $ data ) { $ this -> dataBuffer .= $ this -> buffer -> encodeMessage ( serialize ( $ data ) ) ; if ( $ this -> writeEvent === false ) { $ this -> loop -> addWriteStream ( $ this -> connection , function ( $ stream , LoopInterface $ loop ) { if ( strlen ( $ this -> dataBuffer ) > 0 ) { $ dataWritten = fwrite ( $ stream , $ this -> dataBuffer ) ; $ this -> dataBuffer = substr ( $ this -> dataBuffer , $ dataWritten ) ; if ( strlen ( $ this -> dataBuffer ) <= 0 ) { $ loop -> removeWriteStream ( $ stream ) ; $ this -> writeEvent = false ; } } } ) ; $ this -> writeEvent = true ; } }
Encode the data given into binary message . The message is send to the endpoint
23,525
public function readSync ( ) { $ this -> ThrowOnConnectionInvalid ( ) ; $ this -> loop -> removeReadStream ( $ this -> connection ) ; $ this -> readToBuffer ( ) ; $ this -> attachReadStream ( ) ; }
Reads a singe message from the remote stream
23,526
public function close ( ) { if ( $ this -> connection !== null ) { if ( $ this -> writeEvent ) { $ this -> loop -> removeWriteStream ( $ this -> connection ) ; } $ this -> loop -> removeReadStream ( $ this -> connection ) ; fclose ( $ this -> connection ) ; $ this -> emit ( 'close' , array ( $ this ) ) ; } $ this -> connection = null ; }
Closes any underlying stream and removes events
23,527
protected function attachReadStream ( ) { $ this -> ThrowOnConnectionInvalid ( ) ; $ this -> loop -> addReadStream ( $ this -> connection , function ( ) { $ this -> readToBuffer ( ) ; } ) ; }
setup the readStream event
23,528
protected function readToBuffer ( ) { $ this -> ThrowOnConnectionInvalid ( ) ; $ message = stream_socket_recvfrom ( $ this -> connection , 1024 , 0 , $ peer ) ; if ( $ message !== '' && $ message !== false ) { $ this -> buffer -> pushData ( $ message ) ; foreach ( $ this -> buffer -> getMessages ( ) as $ messageData ) { $ messageData = unserialize ( $ messageData ) ; $ this -> emit ( 'message' , array ( $ this , $ messageData ) ) ; } } else { $ this -> close ( ) ; } }
reads a block of data to the buffer
23,529
public function setup ( ) { $ app = $ this -> getApplication ( ) ; $ options = $ app -> config ( 'doctrine' ) ; if ( is_array ( $ options ) ) { $ this -> setOptions ( $ this -> options , $ options ) ; } $ proxyDir = $ this -> getOption ( 'proxy_path' ) ; $ cache = DoctrineCacheFactory :: configureCache ( $ this -> getOption ( 'cache_driver' ) ) ; $ config = Setup :: createConfiguration ( ! ! $ app -> config ( 'debug' ) , $ proxyDir , $ cache ) ; $ config -> setNamingStrategy ( new UnderscoreNamingStrategy ( ) ) ; $ this -> setupAnnotationMetadata ( ) ; if ( ! $ this -> setupMetadataDriver ( $ config ) ) { throw new \ RuntimeException ( 'No Metadata Driver defined' ) ; } $ config -> setAutoGenerateProxyClasses ( $ this -> getOption ( 'auto_generate_proxies' , true ) == true ) ; $ connection = $ this -> getOption ( 'connection' ) ; $ app -> container -> singleton ( 'entityManager' , function ( ) use ( $ connection , $ config ) { return EntityManager :: create ( $ connection , $ config ) ; } ) ; }
Set up Doctrine Entity Manager Slim service
23,530
public function loadUserByUsername ( $ username ) { if ( ! $ this -> authTokenService -> isValid ( $ username ) ) { throw new UsernameNotFoundException ( "Invalid Token." ) ; } try { return $ this -> authTokenService -> getUser ( $ username ) ; } catch ( ProgrammerException $ ex ) { throw new UsernameNotFoundException ( $ ex -> getMessage ( ) , $ ex -> getCode ( ) ) ; } }
Returns a user from the token payload if the token is valid and user_id in the payload is found otherwise throws an exception
23,531
protected static function listAssets ( $ directory ) { if ( false === is_dir ( $ directory ) ) { throw new InvalidArgumentException ( sprintf ( "\"%s\" is not a directory" , $ directory ) ) ; } $ assets = [ ] ; foreach ( new DirectoryIterator ( realpath ( $ directory ) ) as $ current ) { if ( true === in_array ( $ current -> getFilename ( ) , [ "." , ".." ] ) || 0 === preg_match ( "/\.zip$/" , $ current -> getFilename ( ) ) ) { continue ; } $ assets [ ] = $ current -> getPathname ( ) ; } sort ( $ assets ) ; return $ assets ; }
List all assets .
23,532
public static function unzipAssets ( $ src , $ dst ) { if ( false === is_dir ( $ dst ) ) { throw new InvalidArgumentException ( sprintf ( "\"%s\" is not a directory" , $ dst ) ) ; } $ result = [ ] ; foreach ( static :: listAssets ( $ src ) as $ current ) { $ zip = new ZipArchive ( ) ; if ( true === $ zip -> open ( $ current ) ) { $ result [ $ current ] = $ zip -> extractTo ( realpath ( $ dst ) ) ; $ zip -> close ( ) ; } } return $ result ; }
Unzip all assets .
23,533
protected function getInstanceConfig ( $ instanceId = 0 ) { $ pluginManager = $ this -> getServiceLocator ( ) -> get ( 'Rcm\Service\PluginManager' ) ; $ instanceConfig = [ ] ; $ pluginName = $ this -> getRcmPluginName ( ) ; if ( $ instanceId > 0 ) { try { $ instanceConfig = $ pluginManager -> getInstanceConfig ( $ instanceId ) ; } catch ( PluginInstanceNotFoundException $ e ) { } } if ( empty ( $ instanceConfig ) ) { $ instanceConfig = $ pluginManager -> getDefaultInstanceConfig ( $ pluginName ) ; } return $ instanceConfig ; }
getInstanceConfig by instance id
23,534
public static function getMaterialDesignColorPalette ( ) { return [ new RedColorProvider ( ) , new PinkColorProvider ( ) , new PurpleColorProvider ( ) , new DeepPurpleColorProvider ( ) , new IndigoColorProvider ( ) , new BlueColorProvider ( ) , new LightBlueColorProvider ( ) , new CyanColorProvider ( ) , new TealColorProvider ( ) , new GreenColorProvider ( ) , new LightGreenColorProvider ( ) , new LimeColorProvider ( ) , new YellowColorProvider ( ) , new AmberColorProvider ( ) , new OrangeColorProvider ( ) , new DeepOrangeColorProvider ( ) , new BrownColorProvider ( ) , new GreyColorProvider ( ) , new BlueGreyColorProvider ( ) , new BlackColorProvider ( ) , new WhiteColorProvider ( ) , ] ; }
Get the Material Design Color Palette .
23,535
public function serializeFormError ( FormInterface $ form ) { $ errors = $ this -> formSerializer -> createFormErrorArray ( $ form ) ; $ responseModel = new ResponseFormErrorModel ( $ errors ) ; return new JsonResponse ( $ responseModel -> getBody ( ) , Response :: HTTP_BAD_REQUEST ) ; }
Returns a serialized error response
23,536
public function isObsolete ( ) { if ( $ this -> refreshNthRequests == 1 || $ this -> isRefreshNeededByProbability ( ) ) { return true ; } if ( isset ( $ _SESSION [ '__HANDLER_REQUESTS_BEFORE_REFRESH' ] ) ) { if ( $ _SESSION [ '__HANDLER_REQUESTS_BEFORE_REFRESH' ] <= 1 ) { return true ; } $ _SESSION [ '__HANDLER_REQUESTS_BEFORE_REFRESH' ] -- ; } if ( isset ( $ _SESSION [ '__HANDLER_SECONDS_BEFORE_REFRESH' ] ) ) { $ timeDifference = time ( ) - $ _SESSION [ '__HANDLER_LAST_ACTIVITY_TIMESTAMP' ] ; if ( $ timeDifference >= $ _SESSION [ '__HANDLER_SECONDS_BEFORE_REFRESH' ] ) { return true ; } } return false ; }
Determines if the session needs to be refreshed either because the maximum number of allowed requests has been reached or the timeout has finished .
23,537
private function isRefreshNeededByProbability ( ) { if ( is_null ( $ this -> refreshProbability ) ) { return false ; } $ rand = ( float ) mt_rand ( ) / ( float ) mt_getrandmax ( ) ; if ( $ this -> refreshProbability == 1.0 || $ rand <= $ this -> refreshProbability ) { return true ; } return false ; }
Determines if the probability test of session refresh succeeded according to the desired percent .
23,538
public function make ( ) { try { $ args = func_get_args ( ) ; $ active = $ args [ 1 ] [ 'active' ] ?? true ; if ( ! $ active ) { return false ; } $ this -> widgetName = trim ( ( string ) array_shift ( $ args ) ) ; $ this -> widgetParams = ( array ) array_shift ( $ args ) ; $ this -> widget = $ this -> getWidget ( ) ; return $ this -> getContentFromCache ( ) ; } catch ( \ Exception $ e ) { return sprintf ( trans ( 'common.msg.error' ) , $ e -> getMessage ( ) ) ; } }
Generate a widget .
23,539
protected function getWidgetPath ( ) { $ name = html_clean ( $ this -> widgetName ) ; $ name = str_replace ( [ '.' , '_' ] , ' ' , $ name ) ; $ name = str_replace ( ' ' , '' , ucwords ( $ name ) ) ; $ name = $ this -> namespace . '\\' . $ name . 'Widget' ; if ( ! is_subclass_of ( $ name , WidgetAbstract :: class ) ) { throw new \ Exception ( sprintf ( 'Widget class `%s` not available!' , $ name ) ) ; } return $ name ; }
Get full path with name to widget class location .
23,540
protected function getContent ( ) { $ widget = ( object ) $ this -> widget -> execute ( ) ; $ widget -> cache_key = $ this -> widget -> cacheKeys ( ) ; return trim ( preg_replace ( '/(\s|\r|\n)+</' , '<' , view ( $ this -> widget -> template ( ) , compact ( 'widget' ) ) -> render ( ) ) ) ; return view ( $ this -> widget -> template ( ) , compact ( 'widget' ) ) ; }
Make call and get widget content .
23,541
protected function getContentFromCache ( ) { $ cache_key = $ this -> widget -> cacheKey ( ) ; $ cache_time = $ this -> widget -> cacheTime ( ) ; if ( ! cache ( ) -> has ( $ cache_key ) ) { $ this -> checkWidgetParams ( ) ; $ this -> checkWidgetTemplate ( ) ; } return cache ( ) -> remember ( $ cache_key , $ cache_time , function ( ) { return $ this -> getContent ( ) ; } ) ; }
Gets content from cache or runs widget class otherwise .
23,542
protected function url ( string $ endpoint , ... $ replacements ) : string { return $ this -> client -> baseUrl . vsprintf ( $ endpoint , $ replacements ) ; }
Generate URL from base url and given endpoint .
23,543
protected function createOptionsResolver ( ) : OptionsResolver { $ resolver = new OptionsResolver ( ) ; $ resolver -> setDefined ( 'limit' ) -> setAllowedTypes ( 'limit' , 'int' ) -> setAllowedValues ( 'limit' , function ( $ value ) { return $ value > 0 ; } ) ; $ resolver -> setDefined ( 'offset' ) -> setAllowedTypes ( 'offset' , 'string' ) ; return $ resolver ; }
Create a new OptionsResolver with page and per_page options .
23,544
public static function hasClass ( $ domElement , $ className ) { $ classAttr = $ domElement -> class ; $ classNames = explode ( " " , $ classAttr ) ; return in_array ( $ className , $ classNames ) ; }
Detects if DOM Element has some class in class attribute list .
23,545
public function serializeSingleObject ( array $ data , $ type , $ statusCode = Response :: HTTP_OK ) { $ model = new ResponseModel ( $ data , $ type ) ; return new JsonResponse ( $ model -> getBody ( ) , $ statusCode ) ; }
Serializes the json response
23,546
public function serializeList ( PageModel $ pageModel , $ type , $ page , $ statusCode = Response :: HTTP_OK ) { $ page = new ResponsePageModel ( $ pageModel , $ type , $ page ) ; return new JsonResponse ( $ page -> getBody ( ) , $ statusCode ) ; }
Serializes a paged response
23,547
public function edit ( TemplateRequest $ request , $ template ) { try { $ template = $ request -> template ; $ path = theme_path ( 'views' ) . $ template ; return response ( ) -> json ( [ 'status' => true , 'message' => null , 'file' => [ 'content' => \ File :: get ( $ path ) , 'size' => formatBytes ( \ File :: size ( $ path ) ) , 'modified' => strftime ( '%Y-%m-%d %H:%M' , \ File :: lastModified ( $ path ) ) ] ] , 200 ) ; } catch ( ValidationException $ e ) { $ message = $ e -> validator -> errors ( ) -> first ( ) ; return response ( ) -> json ( [ 'status' => false , 'message' => $ message ] , 200 ) ; } catch ( \ Exception $ e ) { $ message = $ e -> getMessage ( ) ; return response ( ) -> json ( [ 'status' => false , 'message' => $ message ] , 404 ) ; } }
Edit template file by path .
23,548
public function update ( TemplateRequest $ request , $ template ) { try { $ template = $ request -> template ; $ path = theme_path ( 'views' ) . $ template ; $ content = $ request -> content ; if ( \ File :: exists ( $ path ) and \ File :: get ( $ path ) == $ content ) { return response ( ) -> json ( [ 'status' => false , 'message' => sprintf ( __ ( 'msg.not_updated' ) , $ template ) , ] , 200 ) ; } \ File :: put ( $ path , $ content , true ) ; return response ( ) -> json ( [ 'status' => true , 'message' => sprintf ( __ ( 'msg.updated' ) , $ template ) , 'file' => [ 'size' => formatBytes ( \ File :: size ( $ path ) ) , 'modified' => strftime ( '%Y-%m-%d %H:%M' , \ File :: lastModified ( $ path ) ) ] ] , 200 ) ; } catch ( ValidationException $ e ) { $ message = $ e -> validator -> errors ( ) -> first ( ) ; return response ( ) -> json ( [ 'status' => false , 'message' => $ message ] , 200 ) ; } catch ( \ Exception $ e ) { $ message = $ e -> getMessage ( ) ; return response ( ) -> json ( [ 'status' => false , 'message' => $ message ] , 404 ) ; } }
Update template file by path .
23,549
public function destroy ( TemplateRequest $ request , $ template ) { $ template = $ request -> template ; $ path = theme_path ( 'views' ) . $ template ; if ( ! \ File :: exists ( $ path ) ) { return $ this -> makeRedirect ( false , 'admin.templates.index' , sprintf ( __ ( 'msg.not_exists' ) , $ template ) ) ; } if ( ! \ File :: delete ( $ path ) ) { return $ this -> makeRedirect ( false , 'admin.templates.index' , sprintf ( __ ( 'msg.not_deleted' ) , $ template ) ) ; } return $ this -> makeRedirect ( true , 'admin.templates.index' , sprintf ( __ ( 'msg.deleted' ) , $ template ) ) ; }
Unlink template file by path .
23,550
protected function build ( ) { $ factory = $ this -> getFactory ( ) ; foreach ( $ this -> filterConfig as $ field => $ config ) { $ this -> add ( $ factory -> createInput ( $ config ) ) ; } }
build input filter from config
23,551
public function checkCollection ( $ collection , $ notification , $ redirectURL , $ expected = 1 ) { if ( null === $ collection || ( false === is_array ( $ collection ) && false === ( $ collection instanceof Countable ) ) ) { throw new InvalidArgumentException ( "The collection must be a countable" ) ; } if ( $ expected <= count ( $ collection ) ) { return ; } $ eventName = NotificationEvents :: NOTIFICATION_WARNING ; if ( null !== $ this -> getEventDispatcher ( ) && true === $ this -> getEventDispatcher ( ) -> hasListeners ( $ eventName ) ) { $ notification = NotificationFactory :: newWarningNotification ( $ notification ) ; $ event = new NotificationEvent ( $ eventName , $ notification ) ; $ this -> getEventDispatcher ( ) -> dispatch ( $ eventName , $ event ) ; } throw new RedirectResponseException ( $ redirectURL , null ) ; }
Check a collection .
23,552
public function onPostHandleRequestWithCollection ( Collection $ oldCollection , Collection $ newCollection ) { $ deleted = 0 ; foreach ( $ oldCollection as $ current ) { if ( true === $ newCollection -> contains ( $ current ) ) { continue ; } $ this -> getObjectManager ( ) -> remove ( $ current ) ; ++ $ deleted ; } return $ deleted ; }
On post handle request with collection .
23,553
public function onPreHandleRequestWithCollection ( Collection $ collection ) { $ output = new ArrayCollection ( ) ; foreach ( $ collection as $ current ) { $ output -> add ( $ current ) ; } return $ output ; }
On pre handle request with collection .
23,554
public static function isInteger ( $ value ) { if ( is_int ( $ value ) ) { return true ; } elseif ( ! is_string ( $ value ) ) { return false ; } return preg_match ( '/^\d+$/' , $ value ) > 0 ; }
Checks if given value is of type integer
23,555
public static function isFloat ( $ value ) { if ( is_float ( $ value ) ) { return true ; } elseif ( ! is_string ( $ value ) ) { return false ; } return preg_match ( '/^[0-9]+\.[0-9]+$/' , $ value ) > 0 ; }
Checks if given value is of type float
23,556
public static function isDateTime ( $ date , string $ format = null ) : bool { if ( $ date instanceof \ DateTime ) { return true ; } if ( false === is_string ( $ date ) ) { return false ; } if ( $ format ) { return \ DateTime :: createFromFormat ( $ format , $ date ) instanceof \ DateTime ; } return ( bool ) strtotime ( $ date ) ; }
Checks if given value is a valid PHP datetime
23,557
public function updateCron ( EdgarEzCron $ cron ) : bool { try { $ this -> getEntityManager ( ) -> persist ( $ cron ) ; $ this -> getEntityManager ( ) -> flush ( ) ; } catch ( ORMException $ e ) { return false ; } return true ; }
Update cron object .
23,558
public function getClient ( ) { return new S3Client ( [ 'version' => $ this -> apiVersion , 'region' => $ this -> region , 'credentials' => [ 'key' => $ this -> key , 'secret' => $ this -> secret , ] ] ) ; }
Creates a s3 client
23,559
private function extendAuthDriver ( ) { $ auth = $ this -> app [ 'auth' ] ; $ this -> app [ 'auth' ] -> extend ( 'session' , function ( Application $ app , $ name , array $ config ) use ( $ auth ) { $ provider = $ auth -> createUserProvider ( $ config [ 'provider' ] ) ; return tap ( new Guard \ SessionGuard ( $ name , $ provider , $ app [ 'session.store' ] ) , function ( $ guard ) use ( $ app ) { if ( method_exists ( $ guard , 'setCookieJar' ) ) $ guard -> setCookieJar ( $ app [ 'cookie' ] ) ; if ( method_exists ( $ guard , 'setDispatcher' ) ) $ guard -> setDispatcher ( $ app [ 'events' ] ) ; if ( method_exists ( $ guard , 'setRequest' ) ) $ guard -> setRequest ( $ app -> refresh ( 'request' , $ guard , 'setRequest' ) ) ; } ) ; } ) ; }
Extend the auth session driver .
23,560
public function loadUrl ( $ url , $ curl = false ) { if ( $ curl ) { $ content = self :: loadContent ( $ url ) ; if ( empty ( $ content ) ) { throw new Exception ( "Can't get content from " . $ url ) ; } $ this -> loadString ( $ content ) ; } else { $ this -> load_file ( $ url ) ; } }
Inits HtmlDomParser with HTML content by URL .
23,561
private static function loadContent ( $ url ) { $ ch = curl_init ( $ url ) ; $ options = array ( CURLOPT_RETURNTRANSFER => true ) ; curl_setopt_array ( $ ch , $ options ) ; $ content = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; if ( $ content === false ) { throw new Exception ( "Can't get content from " . $ url ) ; } return $ content ; }
Loads HTML content using CURL .
23,562
protected function validate ( $ object ) { $ object = ( object ) $ object ; if ( $ object instanceof $ this -> is ) { return $ object ; } throw new \ DomainException ( sprintf ( "The Asset advertised as being of type %s is actually of type %s" , $ this -> is , get_class ( $ object ) ) ) ; }
Validate that this object is what it advertises .
23,563
public function is ( $ type = null ) { if ( $ type === null ) { return $ this -> is ; } else { return $ type == $ this -> is ; } }
Retrieve the type of object this asset is or test it s type
23,564
public function single ( \ Closure $ closure ) { if ( $ this -> asset === null ) { $ this -> asset = function ( $ asset = null , $ assetManager = null ) use ( $ closure ) { static $ obj ; if ( $ obj === null ) { $ obj = $ this -> validate ( $ closure ( $ asset , $ assetManager ) ) ; } return $ obj ; } ; } return $ this ; }
Store an asset in such a way that when it is retrieved it will always return the same instance .
23,565
private function createFullPages ( ) { $ pageStart = 1 ; $ pageEnd = $ this -> maxPage ; $ tmp = $ this -> currentPage ; $ pager = [ ] ; while ( ( $ pageEnd - $ tmp ) < 4 ) { $ tmp -- ; } if ( $ tmp != $ this -> currentPage ) { $ pageStart = 1 + ( $ tmp - 5 ) ; } if ( $ this -> currentPage > 5 && $ this -> currentPage == $ tmp ) { $ pageStart = 1 + ( $ this -> currentPage - 5 ) ; } $ page = 0 ; for ( $ i = $ pageStart ; $ i < $ tmp ; $ i ++ ) { $ pager [ $ page ] = '<a href="' . $ this -> buildHref ( $ i ) . '">' . $ i . '</a>' ; $ page ++ ; } for ( $ i = $ tmp ; $ i <= $ pageEnd && $ page < 9 ; $ i ++ ) { $ pager [ $ page ] = $ this -> buildAnchor ( $ i ) ; $ page ++ ; } return $ pager ; }
Generates anchors to be displayed when max page is over 9 .
23,566
private function createSimplePages ( ) { $ pager = [ ] ; for ( $ i = 1 ; $ i <= $ this -> maxPage ; $ i ++ ) { $ pager [ $ i - 1 ] = $ this -> buildAnchor ( $ i ) ; } return $ pager ; }
Generates anchors to be displayed when max page is under 10 .
23,567
private function displayPager ( ) { $ pager = ( $ this -> maxPage > 9 ) ? $ this -> createFullPages ( ) : $ this -> createSimplePages ( ) ; echo '<div class="pager">' ; $ this -> displayLeftSide ( ) ; for ( $ i = 0 ; $ i < count ( $ pager ) ; $ i ++ ) { echo $ pager [ $ i ] ; } $ this -> displayRightSide ( ) ; echo "</div>" ; }
Display the complete pager architecture .
23,568
public function save ( SaveEntityInterface $ entity ) { $ entity = $ this -> persist ( $ entity ) ; $ this -> flush ( ) ; return $ entity ; }
Saves an entity to the database
23,569
public function getByIndex ( $ index ) { if ( ! is_numeric ( $ index ) ) { throw new RuntimeException ( 'Index needs to be a numeric value.' ) ; } $ index = ( int ) $ index ; if ( $ index < 0 ) { $ index += count ( $ this -> chain ) ; } return isset ( $ this -> chain [ $ index ] ) ? $ this -> chain [ $ index ] : false ; }
Get the instantiation at a specific index .
23,570
public function getAdminPanel ( MvcEvent $ event ) { $ matchRoute = $ event -> getRouteMatch ( ) ; if ( empty ( $ matchRoute ) ) { return null ; } $ adminPanelController = $ this -> serviceLocator -> get ( \ RcmAdmin \ Controller \ AdminPanelController :: class ) ; $ adminPanelController -> setEvent ( $ event ) ; $ adminWrapper = $ adminPanelController -> getAdminWrapperAction ( ) ; if ( ! $ adminWrapper instanceof ViewModel ) { return ; } $ layout = $ event -> getViewModel ( ) ; $ layout -> addChild ( $ adminWrapper , 'rcmAdminPanel' ) ; }
Get Admin Panel
23,571
public function clone ( $ modelitemId ) { event ( new BeforeClone ( $ this ) ) ; $ this -> beforeClone ( ) ; $ this -> doClone ( ) ; $ this -> afterClone ( ) ; event ( new AfterClone ( $ this ) ) ; }
Clone Action .
23,572
public function excludeOnClone ( ) { return [ $ this -> model -> getKeyName ( ) , $ this -> model -> getCreatedAtColumn ( ) , $ this -> model -> getUpdatedAtColumn ( ) , ] ; }
An Array of Fields to Exclude on Clone .
23,573
protected function materialDesignIconicFontIcon ( MaterialDesignIconicFontIconInterface $ icon ) { $ attributes = [ ] ; $ attributes [ "class" ] [ ] = "zmdi" ; $ attributes [ "class" ] [ ] = MaterialDesignIconicFontIconRenderer :: renderName ( $ icon ) ; $ attributes [ "class" ] [ ] = MaterialDesignIconicFontIconRenderer :: renderSize ( $ icon ) ; $ attributes [ "class" ] [ ] = MaterialDesignIconicFontIconRenderer :: renderFixedWidth ( $ icon ) ; $ attributes [ "class" ] [ ] = MaterialDesignIconicFontIconRenderer :: renderBorder ( $ icon ) ; $ attributes [ "class" ] [ ] = MaterialDesignIconicFontIconRenderer :: renderPull ( $ icon ) ; $ attributes [ "class" ] [ ] = MaterialDesignIconicFontIconRenderer :: renderSpin ( $ icon ) ; $ attributes [ "class" ] [ ] = MaterialDesignIconicFontIconRenderer :: renderRotate ( $ icon ) ; $ attributes [ "class" ] [ ] = MaterialDesignIconicFontIconRenderer :: renderFlip ( $ icon ) ; $ attributes [ "style" ] = MaterialDesignIconicFontIconRenderer :: renderStyle ( $ icon ) ; return static :: coreHTMLElement ( "i" , null , $ attributes ) ; }
Displays a Material Design Iconic Font icon .
23,574
protected function materialDesignIconicFontList ( $ items ) { $ innerHTML = true === is_array ( $ items ) ? implode ( "\n" , $ items ) : $ items ; return static :: coreHTMLElement ( "ul" , $ innerHTML , [ "class" => "zmdi-hc-ul" ] ) ; }
Displays a Material Design Iconic Font list .
23,575
protected function materialDesignIconicFontListIcon ( $ icon , $ content ) { $ glyphicon = null !== $ icon ? StringHelper :: replace ( $ icon , [ "class=\"zmdi" ] , [ "class=\"zmdi-hc-li zmdi" ] ) : "" ; $ innerHTML = null !== $ content ? $ content : "" ; return static :: coreHTMLElement ( "li" , $ glyphicon . $ innerHTML ) ; }
Displays a Material Design Iconic Font list icon .
23,576
public function uploadFileWithFolderAndName ( UploadedFile $ file , $ folderPath , $ fileName ) { $ folderPath = ! empty ( $ folderPath ) ? $ folderPath . '/' : '' ; $ path = $ this -> env . '/' . $ folderPath . $ fileName . '.' . $ file -> guessClientExtension ( ) ; $ result = $ this -> client -> putObject ( [ 'ACL' => 'public-read' , 'Bucket' => $ this -> bucketName , 'SourceFile' => $ file -> getRealPath ( ) , 'Key' => $ path ] ) ; return new FileUploadedModel ( $ path , $ result -> get ( 'ObjectURL' ) , FileUploadedModel :: VENDOR_S3 ) ; }
Uploads a file to amazon s3 using
23,577
public function uploadFile ( UploadedFile $ file ) { $ path = $ this -> env . '/' . md5 ( time ( ) . random_int ( 1 , 100000 ) ) . '.' . $ file -> guessClientExtension ( ) ; $ result = $ this -> client -> putObject ( [ 'ACL' => 'public-read' , 'Bucket' => $ this -> bucketName , 'SourceFile' => $ file -> getRealPath ( ) , 'Key' => $ path ] ) ; return new FileUploadedModel ( $ path , $ result -> get ( 'ObjectURL' ) , FileUploadedModel :: VENDOR_S3 ) ; }
Generates a name for the file and uploads it to s3
23,578
public function send ( ) { $ args = [ $ this -> name , $ this -> value , time ( ) + $ this -> lifetime , $ this -> path , $ this -> domain , $ this -> secure , $ this -> httpOnly ] ; $ function = ( ! $ this -> urlEncodedValue ) ? 'setrawcookie' : 'setcookie' ; call_user_func_array ( $ function , $ args ) ; $ _COOKIE [ $ this -> name ] = $ this -> value ; }
Save the cookie in the HTTP response header using the default PHP functions setcookie or setrawcookie depending on the need to save the cookie value without url encoding .
23,579
public function extendClass ( $ className , $ useAlias = true ) { if ( $ className [ 0 ] === '\\' && $ useAlias ) { $ className = ltrim ( $ className , '\\' ) ; $ this -> useClass ( $ className ) ; $ _p = explode ( '\\' , $ className ) ; $ shortClassName = end ( $ _p ) ; $ this -> extends = new ClassName ( $ shortClassName ) ; } else { $ this -> extends = new ClassName ( $ className ) ; } }
Add extends property
23,580
public function generatePsr0ClassUnder ( $ directory , array $ args = array ( ) ) { $ code = "<?php\n" . $ this -> render ( $ args ) ; $ classPath = $ this -> getPsr0ClassPath ( ) ; $ path = $ directory . DIRECTORY_SEPARATOR . $ classPath ; if ( $ dir = dirname ( $ path ) ) { if ( ! file_exists ( $ dir ) ) { mkdir ( $ dir , 0755 , true ) ; } } if ( file_put_contents ( $ path , $ code ) === false ) { return false ; } return $ path ; }
for Foo \ Bar class
23,581
public function getCron ( string $ alias ) : ? EdgarEzCron { if ( $ cron = $ this -> repository -> getCron ( $ alias ) ) { return $ cron ; } $ crons = $ this -> getCrons ( ) ; if ( isset ( $ crons [ $ alias ] ) ) { $ cron = new EdgarEzCron ( ) ; $ cron -> setAlias ( $ alias ) ; $ cron -> setExpression ( $ crons [ $ alias ] [ 'expression' ] ) ; $ cron -> setArguments ( $ crons [ $ alias ] [ 'arguments' ] ) ; $ cron -> setPriority ( $ crons [ $ alias ] [ 'priority' ] ) ; $ cron -> setEnabled ( $ crons [ $ alias ] [ 'enabled' ] ) ; return $ cron ; } return null ; }
Get Cron by alias .
23,582
public function getCrons ( ) : array { $ crons = $ this -> cronService -> getCrons ( ) ; $ ezCrons = $ this -> repository -> listCrons ( ) ; $ return = [ ] ; foreach ( $ ezCrons as $ ezCron ) { $ return [ $ ezCron -> getAlias ( ) ] = [ 'alias' => $ ezCron -> getAlias ( ) , 'expression' => $ ezCron -> getExpression ( ) , 'arguments' => $ ezCron -> getArguments ( ) , 'priority' => ( int ) $ ezCron -> getPriority ( ) , 'enabled' => ( int ) $ ezCron -> getEnabled ( ) == 1 , ] ; } foreach ( $ crons as $ cron ) { if ( ! isset ( $ return [ $ cron -> getAlias ( ) ] ) ) { $ return [ $ cron -> getAlias ( ) ] = [ 'alias' => $ cron -> getAlias ( ) , 'expression' => $ cron -> getExpression ( ) , 'arguments' => $ cron -> getArguments ( ) , 'priority' => ( int ) $ cron -> getPriority ( ) , 'enabled' => true , ] ; } } return $ return ; }
Return cron list detail .
23,583
public static function renderOption ( $ option , TranslatorInterface $ translator = null ) { if ( null === $ option ) { return null !== $ translator ? $ translator -> trans ( "label.empty_selection" ) : "Empty selection" ; } if ( true === ( $ option instanceof TranslatedChoiceLabelInterface ) ) { $ output = $ option -> getTranslatedChoiceLabel ( $ translator ) ; } else if ( true === ( $ option instanceof ChoiceLabelInterface ) ) { $ output = $ option -> getChoiceLabel ( ) ; } else { $ output = "This option must implements [Translated]ChoiceLabelInterface" ; } if ( true === ( $ option instanceof AlphabeticalTreeNodeInterface ) ) { $ multiplier = AlphabeticalTreeNodeHelper :: getLevel ( $ option ) ; $ nbsp = html_entity_decode ( "&nbsp;" ) ; $ symbol = html_entity_decode ( 0 === $ multiplier ? "&#9472;" : "&#9492;" ) ; $ output = implode ( "" , [ str_repeat ( $ nbsp , $ multiplier * 3 ) , $ symbol , $ nbsp , $ output ] ) ; } return $ output ; }
Render an option .
23,584
public static function newEntityType ( $ class , array $ choices = [ ] , array $ options = [ ] ) { if ( false === array_key_exists ( "empty" , $ options ) ) { $ options [ "empty" ] = false ; } if ( false === array_key_exists ( "translator" , $ options ) ) { $ options [ "translator" ] = null ; } $ output = [ "class" => $ class , "choices" => [ ] , "choice_label" => function ( $ entity ) use ( $ options ) { return FormRenderer :: renderOption ( $ entity , $ options [ "translator" ] ) ; } , ] ; if ( true === $ options [ "empty" ] ) { $ output [ "choices" ] [ ] = null ; } $ output [ "choices" ] = array_merge ( $ output [ "choices" ] , $ choices ) ; return $ output ; }
Create an entity type .
23,585
public function listAction ( ) : Response { $ this -> permissionAccess ( 'uicron' , 'list' ) ; $ crons = $ this -> cronService -> getCrons ( ) ; return $ this -> render ( '@EdgarEzUICron/cron/list.html.twig' , [ 'crons' => $ crons , ] ) ; }
List all crons .
23,586
protected function permissionAccess ( string $ module , string $ function ) : ? RedirectResponse { if ( ! $ this -> permissionResolver -> hasAccess ( $ module , $ function ) ) { $ this -> notificationHandler -> error ( $ this -> translator -> trans ( 'edgar.ezuicron.permission.failed' , [ ] , 'edgarezuicron' ) ) ; return new RedirectResponse ( $ this -> generateUrl ( 'ezplatform.dashboard' , [ ] ) ) ; } return null ; }
Check if user has permissions to access cron functions .
23,587
public function path ( string $ thumbSize = null ) { return $ this -> attributes [ 'type' ] . DS . $ this -> attributes [ 'category' ] . ( $ thumbSize ? DS . $ thumbSize : '' ) . DS . $ this -> attributes [ 'name' ] . '.' . $ this -> attributes [ 'extension' ] ; }
Get path to file . Used in BBCMS \ Models \ Mutators \ FileMutators and BBCMS \ Models \ Observers \ FileObserver .
23,588
protected function storeAsZip ( UploadedFile $ file , array $ data ) { $ disk = $ this -> storageDisk ( $ data [ 'disk' ] ) ; $ zipname = $ disk -> getDriver ( ) -> getAdapter ( ) -> getPathPrefix ( ) . $ data [ 'type' ] . DS . $ data [ 'category' ] . DS . $ data [ 'name' ] . '.' . $ data [ 'extension' ] . '.zip' ; if ( $ disk -> exists ( $ zipname ) ) { throw new FileException ( sprintf ( 'File with name `%s` already exists!' , $ zipname ) ) ; } $ zip = new \ ZipArchive ; $ zip -> open ( $ zipname , \ ZipArchive :: CREATE ) ; $ zip -> addFile ( $ file -> getRealPath ( ) , $ data [ 'name' ] . '.' . $ data [ 'extension' ] ) ; $ zip -> close ( ) ; $ this -> attributes [ 'name' ] = $ data [ 'name' ] . '.' . $ data [ 'extension' ] ; $ this -> attributes [ 'extension' ] = 'zip' ; $ this -> attributes [ 'filesize' ] = filesize ( $ zipname ) ; }
Manipulate whith archive file .
23,589
protected function storeAsImage ( UploadedFile $ file , array $ data ) { $ this -> storeAsFile ( $ file , $ data ) ; $ properties = [ ] ; $ disk = $ this -> storageDisk ( $ data [ 'disk' ] ) ; $ path_prefix = $ data [ 'type' ] . DS . $ data [ 'category' ] . DS ; $ path_suffix = DS . $ data [ 'name' ] . '.' . $ data [ 'extension' ] ; $ quality = setting ( 'files.images_quality' , 75 ) ; $ is_convert = setting ( 'files.images_is_convert' , true ) ; $ image = $ this -> imageResave ( $ this -> getAbsolutePathAttribute ( ) , $ disk -> path ( $ path_prefix . trim ( $ path_suffix , DS ) ) , setting ( 'files.images_max_width' , 3840 ) , setting ( 'files.images_max_height' , 2160 ) , $ quality , $ is_convert ) ; if ( $ image ) { if ( $ data [ 'extension' ] != $ image [ 'extension' ] ) { $ disk -> delete ( $ this -> path ) ; } $ this -> attributes [ 'mime_type' ] = $ image [ 'mime_type' ] ; $ this -> attributes [ 'extension' ] = $ image [ 'extension' ] ; $ this -> attributes [ 'filesize' ] = $ image [ 'filesize' ] ; $ properties = [ 'width' => $ image [ 'width' ] , 'height' => $ image [ 'height' ] , ] ; $ path_suffix = DS . $ data [ 'name' ] . '.' . $ image [ 'extension' ] ; } foreach ( $ this -> thumbSizes ( ) as $ key => $ value ) { @ $ disk -> makeDirectory ( $ path_prefix . $ key ) ; $ image = $ this -> imageResave ( $ this -> getAbsolutePathAttribute ( ) , $ disk -> path ( $ path_prefix . $ key . $ path_suffix ) , setting ( 'files.images_' . $ key . '_width' , $ value ) , setting ( 'files.images_' . $ key . '_height' , $ value ) , $ quality , $ is_convert ) ; if ( ! $ image ) break ; $ properties += [ $ key => [ 'width' => $ image [ 'width' ] , 'height' => $ image [ 'height' ] , 'filesize' => $ image [ 'filesize' ] , ] ] ; } return $ this -> setAttribute ( 'properties' , $ properties ) ; }
Manipulate whith image file .
23,590
public function getCommand ( $ id = null ) { $ uri = ( $ id ) ? 'command/' . $ id : 'command' ; $ response = [ 'uri' => $ uri , 'type' => 'get' , 'data' => [ ] ] ; return $ this -> processRequest ( $ response ) ; }
Queries the status of a previously started command or all currently started commands .
23,591
public function postCommand ( $ name , array $ params = null ) { $ uri = 'command' ; $ uriData = [ 'name' => $ name ] ; if ( is_array ( $ params ) ) { foreach ( $ params as $ key => $ value ) { $ uriData [ $ key ] = $ value ; } } $ response = [ 'uri' => $ uri , 'type' => 'post' , 'data' => $ uriData ] ; return $ this -> processRequest ( $ response ) ; }
Publish a new command for Sonarr to run . These commands are executed asynchronously ; use GET to retrieve the current status .
23,592
public function getRelease ( $ episodeId ) { $ uri = 'release' ; $ uriData = [ 'episodeId' => $ episodeId ] ; $ response = [ 'uri' => $ uri , 'type' => 'get' , 'data' => $ uriData ] ; return $ this -> processRequest ( $ response ) ; }
Get release by episode id
23,593
public function postReleasePush ( $ title , $ downloadUrl , $ downloadProtocol , $ publishDate ) { $ uri = 'release' ; $ uriData = [ 'title' => $ title , 'downloadUrl' => $ downloadUrl , 'downloadProtocol' => $ downloadProtocol , 'publishDate' => $ publishDate ] ; $ response = [ 'uri' => $ uri , 'type' => 'post' , 'data' => $ uriData ] ; return $ this -> processRequest ( $ response ) ; }
Push a release to download client
23,594
public function postSeries ( array $ data , $ onlyFutureEpisodes = true ) { $ uri = 'series' ; $ uriData = [ ] ; $ uriData [ 'tvdbId' ] = $ data [ 'tvdbId' ] ; $ uriData [ 'title' ] = $ data [ 'title' ] ; $ uriData [ 'qualityProfileId' ] = $ data [ 'qualityProfileId' ] ; if ( array_key_exists ( 'titleSlug' , $ data ) ) { $ uriData [ 'titleSlug' ] = $ data [ 'titleSlug' ] ; } if ( array_key_exists ( 'seasons' , $ data ) ) { $ uriData [ 'seasons' ] = $ data [ 'seasons' ] ; } if ( array_key_exists ( 'path' , $ data ) ) { $ uriData [ 'path' ] = $ data [ 'path' ] ; } if ( array_key_exists ( 'rootFolderPath' , $ data ) ) { $ uriData [ 'rootFolderPath' ] = $ data [ 'rootFolderPath' ] ; } if ( array_key_exists ( 'tvRageId' , $ data ) ) { $ uriData [ 'tvRageId' ] = $ data [ 'tvRageId' ] ; } $ uriData [ 'seasonFolder' ] = ( array_key_exists ( 'seasonFolder' , $ data ) ) ? $ data [ 'seasonFolder' ] : true ; if ( array_key_exists ( 'monitored' , $ data ) ) { $ uriData [ 'monitored' ] = $ data [ 'monitored' ] ; } if ( $ onlyFutureEpisodes ) { $ uriData [ 'addOptions' ] = [ 'ignoreEpisodesWithFiles' => true , 'ignoreEpisodesWithoutFiles' => true ] ; } $ response = [ 'uri' => $ uri , 'type' => 'post' , 'data' => $ uriData ] ; return $ this -> processRequest ( $ response ) ; }
Adds a new series to your collection
23,595
public function deleteSeries ( $ id , $ deleteFiles = true ) { $ uri = 'series' ; $ uriData = [ ] ; $ uriData [ 'deleteFiles' ] = ( $ deleteFiles ) ? 'true' : 'false' ; $ response = [ 'uri' => $ uri . '/' . $ id , 'type' => 'delete' , 'data' => $ uriData ] ; return $ this -> processRequest ( $ response ) ; }
Delete the series with the given ID
23,596
protected function processRequest ( array $ request ) { try { $ response = $ this -> _request ( [ 'uri' => $ request [ 'uri' ] , 'type' => $ request [ 'type' ] , 'data' => $ request [ 'data' ] ] ) ; } catch ( \ Exception $ e ) { echo json_encode ( array ( 'error' => array ( 'msg' => $ e -> getMessage ( ) , 'code' => $ e -> getCode ( ) , ) , ) ) ; exit ( ) ; } return $ response -> getBody ( ) -> getContents ( ) ; }
Process requests catch exceptions return json response
23,597
public function add ( $ items = [ ] ) { if ( ! is_array ( $ items ) || func_num_args ( ) > 1 ) { $ items = func_get_args ( ) ; } $ this -> push ( $ this -> formatInnerField ( null , $ items ) ) ; }
Allows adding fields to the Attribute Collection .
23,598
private function createField ( $ type , $ name , $ value , $ inner ) { if ( $ this -> hasOptionsMethod ( $ name ) ) { $ inner = array_merge ( $ inner , [ 'options' => $ this -> getOptions ( $ name ) ] ) ; } return $ this -> fields -> create ( $ type , $ name , $ this -> getValue ( $ name ) , $ inner ) ; }
Create and return a Field Instance .
23,599
public static function getCheckbox ( $ checked ) { if ( true === $ checked ) { return sprintf ( "<fg=green;options=bold>%s</>" , OSHelper :: isWindows ( ) ? "OK" : "\xE2\x9C\x94" ) ; } return sprintf ( "<fg=yellow;options=bold>%s</>" , OSHelper :: isWindows ( ) ? "KO" : "!" ) ; }
Get a checkbox .