idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
17,000
public function connect ( ) { if ( $ this -> _connection && $ this -> _connection -> connect ( ) ) { return true ; } $ config = $ this -> _config [ 'connection' ] + array ( 'hostnames' => 'localhost:27017' ) ; unset ( $ this -> _config [ 'connection' ] ) ; if ( isset ( $ config [ 'username' ] ) && isset ( $ config [ 'p...
Connect to MongoDB select database
17,001
public function disconnect ( ) { if ( $ this -> _connection ) { try { $ this -> _connection -> close ( ) ; } catch ( \ Exception $ e ) { } } $ this -> _db = $ this -> _connection = null ; }
Disconnect from MongoDB
17,002
private function _decodeBinanceException ( $ message ) { $ msg = json_decode ( $ message , true ) ; $ this -> code = isset ( $ msg [ 'code' ] ) ? $ msg [ 'code' ] : 0 ; $ this -> message = isset ( $ msg [ 'msg' ] ) ? $ msg [ 'msg' ] : '' ; }
Decodes received exception message .
17,003
public static function factory ( $ path , $ httpMethod = HttpMethods :: GET , $ handlerMethod = null ) { return new ApiEndpoint ( $ path , $ httpMethod , $ handlerMethod ) ; }
Returns endpoint with default values
17,004
public static function get ( $ path , $ handlerMethod = null ) { return self :: factory ( $ path , HttpMethods :: GET , $ handlerMethod ) ; }
Returns pre - configured GET endpoint
17,005
public static function post ( $ path , $ handlerMethod = null ) { return self :: factory ( $ path , HttpMethods :: POST , $ handlerMethod ) ; }
Returns pre - configured POST endpoint
17,006
public static function put ( $ path , $ handlerMethod = null ) { return self :: factory ( $ path , HttpMethods :: PUT , $ handlerMethod ) ; }
Returns pre - configured PUT endpoint
17,007
public static function delete ( $ path , $ handlerMethod = null ) { return self :: factory ( $ path , HttpMethods :: DELETE , $ handlerMethod ) ; }
Returns pre - configured DELETE endpoint
17,008
public static function head ( $ path , $ handlerMethod = null ) { return self :: factory ( $ path , HttpMethods :: HEAD , $ handlerMethod ) ; }
Returns pre - configured HEAD endpoint
17,009
public static function options ( $ path , $ handlerMethod = null ) { return self :: factory ( $ path , HttpMethods :: OPTIONS , $ handlerMethod ) ; }
Returns pre - configured OPTIONS endpoint
17,010
public static function patch ( $ path , $ handlerMethod = null ) { return self :: factory ( $ path , HttpMethods :: PATCH , $ handlerMethod ) ; }
Returns pre - configured PATCH endpoint
17,011
public function get ( $ index = 0 ) { if ( is_int ( $ index ) ) { if ( $ index + 1 > $ this -> count ( ) ) { return null ; } else { return current ( array_slice ( $ this -> _items , $ index , 1 ) ) ; } } else { if ( $ index instanceof \ MongoId ) { $ index = ( string ) $ index ; } if ( $ this -> has ( $ index ) ) { ret...
Get item by numeric index or MongoId
17,012
public function map ( \ Closure $ callback ) { $ this -> _items = array_map ( $ callback , $ this -> _items ) ; return $ this ; }
Run a map over the collection using the given Closure
17,013
public function makeRef ( ) { $ data = array ( ) ; foreach ( $ this -> _items as $ item ) { $ data [ ] = $ item -> makeRef ( ) ; } return $ data ; }
make a MongoRefs array of items
17,014
protected function _makeApiRequest ( $ type , $ endPoint , $ securityType = 'NONE' , $ params = [ ] ) { $ params = array_filter ( $ params , 'strlen' ) ; switch ( strtoupper ( $ securityType ) ) { default : case 'NONE' : $ client = new Client ( [ 'http_errors' => false ] ) ; $ url = ConnectionDetails :: API_URL . Conne...
Does an HTTP request to the given endpoint with the given parameters .
17,015
protected function _makeWebsocketRequest ( $ type , $ params , $ once = false ) { switch ( strtoupper ( $ type ) ) { default : case 'DEPTH' : $ url = ConnectionDetails :: WEBSOCKET_URL . strtolower ( $ params [ 'symbol' ] ) . '@depth' ; break ; case 'KLINE' : $ url = ConnectionDetails :: WEBSOCKET_URL . strtolower ( $ ...
Opens a websocket connection and transmits received messages until closed .
17,016
public function update ( array $ cleanData , $ isInit = false ) { if ( $ isInit ) { $ attrs = $ this -> getAttrs ( ) ; foreach ( $ cleanData as $ key => $ value ) { if ( ( $ value instanceof Model ) && isset ( $ attrs [ $ key ] ) && isset ( $ attrs [ $ key ] [ 'type' ] ) && ( $ attrs [ $ key ] [ 'type' ] == self :: DAT...
Update data by a array
17,017
public function mutate ( $ updateQuery , $ options = array ( ) ) { if ( ! is_array ( $ updateQuery ) ) throw new \ Exception ( '$updateQuery should be an array' ) ; if ( ! is_array ( $ options ) ) throw new \ Exception ( '$options should be an array' ) ; $ default = array ( 'w' => 1 ) ; $ options = array_merge ( $ defa...
Mutate data by direct query
17,018
public function getId ( ) { $ class = get_called_class ( ) ; if ( isset ( $ this -> cleanData [ '_id' ] ) ) { if ( $ class :: $ customIdType === true ) return $ this -> cleanData [ '_id' ] ; return new \ MongoId ( $ this -> cleanData [ '_id' ] ) ; } elseif ( isset ( $ this -> _tempId ) ) { return $ this -> _tempId ; } ...
get MongoId of this record
17,019
public function save ( $ options = array ( ) ) { if ( $ this -> isEmbed ( ) ) { return false ; } $ this -> processReferencesChanged ( ) ; $ this -> processEmbedsChanged ( ) ; if ( $ this -> _exist && empty ( $ this -> dirtyData ) && empty ( $ this -> unsetData ) ) return true ; $ this -> __preSave ( ) ; if ( $ this -> ...
Save to database
17,020
public function toArray ( $ ignore = array ( '_type' ) , $ recursive = false , $ deep = 3 ) { if ( ! empty ( $ ignore ) ) { $ ignores = array ( ) ; foreach ( $ ignore as $ val ) { $ ignores [ $ val ] = 1 ; } $ ignore = $ ignores ; } if ( $ recursive === true && $ deep > 0 ) { $ attrs = $ this -> getAttrs ( ) ; foreach ...
Export datas to array
17,021
public static function id ( $ id ) { $ class = get_called_class ( ) ; if ( $ class :: $ customIdType !== true ) { if ( $ id && strlen ( $ id ) == 24 ) { $ id = new \ MongoId ( $ id ) ; } } return self :: one ( array ( "_id" => $ id ) ) ; }
Retrieve a record by MongoId
17,022
public static function one ( $ criteria = array ( ) , $ fields = array ( ) ) { self :: processCriteriaWithType ( $ criteria ) ; $ result = self :: connection ( ) -> findOne ( static :: $ collection , $ criteria , self :: mapFields ( $ fields ) ) ; if ( $ result ) { return Hydrator :: hydrate ( get_called_class ( ) , $ ...
Retrieve a record
17,023
public static function count ( $ criteria = array ( ) ) { self :: processCriteriaWithType ( $ criteria ) ; $ count = self :: connection ( ) -> count ( self :: collectionName ( ) , $ criteria ) ; return $ count ; }
Count of records
17,024
public static function ref ( $ ref ) { if ( isset ( $ ref [ '$id' ] ) ) { if ( $ ref [ '$ref' ] == self :: collectionName ( ) ) { return self :: id ( $ ref [ '$id' ] ) ; } } return null ; }
Retrieve a record by MongoRef
17,025
public function setEmbed ( $ is_embed ) { $ this -> _isEmbed = $ is_embed ; if ( $ is_embed ) { unset ( $ this -> _connection ) ; unset ( $ this -> _exist ) ; } }
Set the embed status of model .
17,026
protected function initTypes ( ) { $ class = $ this -> getClassName ( false ) ; $ types = $ this -> getModelTypes ( ) ; $ type = $ this -> _type ; if ( ! $ type || ! is_array ( $ type ) ) { if ( ! empty ( $ types ) ) { $ this -> _type = $ types ; } } elseif ( ! in_array ( $ class , $ type ) ) { $ type [ ] = $ class ; $...
Initialize the _type attribute for the model
17,027
protected static function cacheAttrsMap ( ) { $ class = get_called_class ( ) ; $ attrs = $ class :: getAttrs ( ) ; $ private = & $ class :: getPrivateData ( ) ; if ( ! isset ( $ private [ 'attrsMapCache' ] ) ) { $ private [ 'attrsMapCache' ] = array ( ) ; } $ cache = & $ private [ 'attrsMapCache' ] ; if ( empty ( $ cac...
Cache attrs map
17,028
protected function dbName ( ) { $ dbName = "default" ; $ config = $ this :: $ config ; $ configs = ConnectionManager :: config ( $ config ) ; if ( $ configs ) { $ dbName = $ configs [ 'connection' ] [ 'database' ] ; } return $ dbName ; }
Get current database name
17,029
protected function processReferencesChanged ( ) { $ cache = $ this -> _cache ; $ attrs = $ this -> getAttrs ( ) ; foreach ( $ cache as $ key => $ item ) { if ( ! isset ( $ attrs [ $ key ] ) ) continue ; $ attr = $ attrs [ $ key ] ; if ( $ attr [ 'type' ] == self :: DATA_TYPE_REFERENCES ) { if ( $ item instanceof Collec...
Update the references attribute for model s instance when that references data has changed .
17,030
protected function processEmbedsChanged ( ) { $ cache = $ this -> _cache ; $ attrs = $ this -> getAttrs ( ) ; foreach ( $ cache as $ key => $ item ) { if ( ! isset ( $ attrs [ $ key ] ) ) continue ; $ attr = $ attrs [ $ key ] ; if ( $ attr [ 'type' ] == self :: DATA_TYPE_EMBED ) { $ item -> processEmbedsChanged ( ) ; i...
Update the embeds attribute for model s instance when that embeds data has changed .
17,031
protected function fillEmbed ( $ key , $ value ) { $ attrs = $ this -> getAttrs ( ) ; $ cache = & $ this -> _cache ; $ embed = $ attrs [ $ key ] ; $ model = $ embed [ 'model' ] ; $ type = $ embed [ 'type' ] ; if ( $ type == self :: DATA_TYPE_EMBED ) { $ model = $ embed [ 'model' ] ; if ( $ value instanceof $ model ) { ...
Fill the Embed attribute .
17,032
protected function loadEmbed ( $ key ) { $ attrs = $ this -> getAttrs ( ) ; $ embed = $ attrs [ $ key ] ; $ cache = & $ this -> _cache ; if ( isset ( $ this -> cleanData [ $ key ] ) ) { $ value = $ this -> cleanData [ $ key ] ; } else { $ value = null ; } $ model = $ embed [ 'model' ] ; $ type = $ embed [ 'type' ] ; if...
Load the embed attribute
17,033
protected function initAttrs ( ) { $ attrs = self :: getAttrs ( ) ; foreach ( $ attrs as $ key => $ attr ) { if ( ! isset ( $ attr [ 'default' ] ) ) continue ; if ( ! isset ( $ this -> cleanData [ $ key ] ) ) { $ this -> $ key = $ attr [ 'default' ] ; } } }
Initialize attributes with default value
17,034
protected static function getModelTypes ( ) { $ class = get_called_class ( ) ; if ( $ class :: $ useType === false ) { return array ( ) ; } $ class_name = $ class :: getClassName ( false ) ; $ parent = get_parent_class ( $ class ) ; if ( $ parent ) { $ names_parent = $ parent :: getModelTypes ( ) ; $ names = array_merg...
Get types of model type is the class_name without namespace of Model
17,035
public static function crud ( $ prefix , $ name = null ) { return self :: factory ( $ prefix , $ name ) -> endpoint ( ApiEndpoint :: all ( ) ) -> endpoint ( ApiEndpoint :: find ( ) ) -> endpoint ( ApiEndpoint :: create ( ) ) -> endpoint ( ApiEndpoint :: update ( ) ) -> endpoint ( ApiEndpoint :: remove ( ) ) ; }
Returns resource with default values & all find create update and delete endpoints pre - configured
17,036
public static function factory ( $ prefix , $ name = null ) { $ calledClass = get_called_class ( ) ; $ resource = new $ calledClass ( $ prefix ) ; if ( ! $ resource -> getItemKey ( ) ) { $ resource -> itemKey ( 'items' ) ; } if ( ! $ resource -> getCollectionKey ( ) ) { $ resource -> collectionKey ( 'items' ) ; } if ( ...
Returns resource with default values
17,037
public function render ( ) { return view ( 'toggle-switch-button::components.toggle-switch-button' , [ 'name' => $ this -> name , 'checked' => $ this -> checked , 'icon' => $ this -> icon , 'label' => $ this -> label , ] ) -> render ( ) ; }
Render the toggle switch button .
17,038
public function addMyFriends ( Collection $ users ) { foreach ( $ users as $ user ) { $ this -> addMyFriend ( $ user ) ; } return $ this ; }
Add myFriends - mandatory with ManyToMany
17,039
public function createErrorView ( $ errorMessage , $ exception , $ displayExceptions = false , $ displayNavMenu = false ) { $ viewModel = new ViewModel ( array ( 'navMenu' => $ displayNavMenu , 'display_exceptions' => $ displayExceptions , 'errorMessage' => $ errorMessage , 'exception' => $ exception , ) ) ; $ viewMode...
Create error view
17,040
public function logoutAction ( ) { $ auth = $ this -> getServiceLocator ( ) -> get ( 'Zend\Authentication\AuthenticationService' ) ; if ( $ auth -> hasIdentity ( ) ) { $ auth -> clearIdentity ( ) ; $ sessionManager = new SessionManager ( ) ; $ sessionManager -> forgetMe ( ) ; } return $ this -> redirect ( ) -> toRoute ...
Log out action
17,041
public function editProfileAction ( ) { if ( ! $ user = $ this -> identity ( ) ) { return $ this -> redirect ( ) -> toRoute ( $ this -> getOptions ( ) -> getLoginRedirectRoute ( ) ) ; } $ form = $ this -> getUserFormHelper ( ) -> createUserForm ( $ user , 'EditProfile' ) ; $ email = $ user -> getEmail ( ) ; $ username ...
Edit Profile Action
17,042
public function confirmEmailAction ( ) { $ token = $ this -> params ( ) -> fromRoute ( 'id' ) ; try { $ entityManager = $ this -> getEntityManager ( ) ; if ( $ token !== '' && $ user = $ entityManager -> getRepository ( 'CsnUser\Entity\User' ) -> findOneBy ( array ( 'registrationToken' => $ token ) ) ) { $ user -> setR...
Confirm Email Action
17,043
public function confirmEmailChangePasswordAction ( ) { $ token = $ this -> params ( ) -> fromRoute ( 'id' ) ; try { $ entityManager = $ this -> getEntityManager ( ) ; if ( $ token !== '' && $ user = $ entityManager -> getRepository ( 'CsnUser\Entity\User' ) -> findOneBy ( array ( 'registrationToken' => $ token ) ) ) { ...
Confirm Email Change Action
17,044
private function getBaseUrl ( ) { $ uri = $ this -> getRequest ( ) -> getUri ( ) ; return sprintf ( '%s://%s' , $ uri -> getScheme ( ) , $ uri -> getHost ( ) ) ; }
Get Base Url
17,045
public function recordVideo ( $ filename , $ length , $ timeUnit = self :: TIMEUNIT_SECOND ) { if ( empty ( $ filename ) ) { throw new \ InvalidArgumentException ( 'Filename required' ) ; } $ this -> valueArguments [ 'output' ] = $ filename ; $ this -> timeout ( $ length , $ timeUnit ) ; $ this -> execute ( $ this -> b...
Record a video clip for the specified amount of time and save with the given filename
17,046
public function flip ( $ value = true ) { $ this -> booleanArguments [ 'vflip' ] = ( bool ) $ value ; $ this -> booleanArguments [ 'hflip' ] = ( bool ) $ value ; return $ this ; }
Flips the image both vertically and horizontally
17,047
public function exposure ( $ mode ) { $ exposureModes = [ self :: EXPOSURE_AUTO , self :: EXPOSURE_NIGHT , self :: EXPOSURE_NIGHTPREVIEW , self :: EXPOSURE_BACKLIGHT , self :: EXPOSURE_SPOTLIGHT , self :: EXPOSURE_SPORTS , self :: EXPOSURE_SNOW , self :: EXPOSURE_BEACH , self :: EXPOSURE_VERYLONG , self :: EXPOSURE_FIX...
Set exposure mode
17,048
public function effect ( $ mode ) { $ effectModes = [ self :: EFFECT_NONE , self :: EFFECT_NEGATIVE , self :: EFFECT_SOLARISE , self :: EFFECT_POSTERISE , self :: EFFECT_WHITEBOARD , self :: EFFECT_BLACKBOARD , self :: EFFECT_SKETCH , self :: EFFECT_DENOISE , self :: EFFECT_EMBOSS , self :: EFFECT_OILPAINT , self :: EF...
Set an effect to be applied to the image
17,049
public function metering ( $ mode ) { $ meteringModes = [ self :: METERING_AVERAGE , self :: METERING_SPOT , self :: METERING_BACKLIT , self :: METERING_MATRIX , ] ; $ this -> assertInArray ( $ mode , $ meteringModes ) ; $ this -> valueArguments [ 'metering' ] = $ mode ; return $ this ; }
Set metering mode
17,050
public function rotate ( $ degrees ) { $ supportedRotations = [ 0 , 90 , 180 , 270 , ] ; $ this -> assertInArray ( $ degrees , $ supportedRotations ) ; $ this -> valueArguments [ 'rotation' ] = $ degrees ; return $ this ; }
Set image rotation
17,051
public function shutterSpeed ( $ value , $ unit = self :: TIMEUNIT_SECOND ) { $ this -> assertPositiveNumber ( $ value ) ; $ this -> valueArguments [ 'shutter' ] = $ this -> convertTimeUnit ( $ value , $ unit , self :: TIMEUNIT_MICROSECOND ) ; return $ this ; }
Set the shutter speed to the specified time .
17,052
public function timeout ( $ value , $ unit = self :: TIMEUNIT_SECOND ) { $ this -> assertPositiveNumber ( $ value ) ; $ this -> valueArguments [ 'timeout' ] = $ this -> convertTimeUnit ( $ value , $ unit , self :: TIMEUNIT_MILLISECOND ) ; return $ this ; }
Time before takes picture default is 5 seconds
17,053
public function encoding ( $ mode ) { $ encodings = [ self :: ENCODING_JPG , self :: ENCODING_BMP , self :: ENCODING_GIF , self :: ENCODING_PNG , ] ; $ this -> assertInArray ( $ mode , $ encodings ) ; $ this -> valueArguments [ 'encoding' ] = $ mode ; return $ this ; }
Encoding to use for output file
17,054
public function addExif ( $ tagName , $ value ) { if ( empty ( $ tagName ) ) { throw new \ InvalidArgumentException ( 'Tag name required' ) ; } if ( '' === ( string ) $ value ) { throw new \ InvalidArgumentException ( 'Non-empty value required' ) ; } if ( ! isset ( $ this -> valueArguments [ 'exif' ] ) || ! is_array ( ...
Add EXIF tag to apply to pictures .
17,055
public function setExif ( array $ tags ) { $ this -> valueArguments [ 'exif' ] = [ ] ; foreach ( $ tags as $ tagName => $ value ) { $ this -> addExif ( $ tagName , $ value ) ; } return $ this ; }
Add multiple EXIF tags at once
17,056
public function takePicture ( $ filename ) { if ( empty ( $ filename ) ) { throw new \ InvalidArgumentException ( 'Filename required' ) ; } $ this -> valueArguments [ 'output' ] = $ filename ; $ this -> execute ( $ this -> buildCommand ( ) ) ; }
Take a picture and save with the given filename
17,057
public function startTimelapse ( $ filename , $ interval , $ length , $ timeUnit = self :: TIMEUNIT_SECOND ) { if ( empty ( $ filename ) ) { throw new \ InvalidArgumentException ( 'Filename required' ) ; } $ this -> valueArguments [ 'output' ] = $ filename ; $ this -> timeout ( $ length , $ timeUnit ) ; $ this -> timel...
Take pictures with timelapse mode .
17,058
public function actionIndex ( ) { $ dataHandler = new SitemapDataHandler ( $ this -> savePathAlias , $ this -> sitemapFileName , [ 'builderConfig' => $ this -> builderConfig , ] ) ; $ models = $ dataHandler -> getModelsClasses ( $ this -> modelsPath , $ this -> modelsNamespace ) ; $ dataHandler -> handleModels ( $ mode...
Index action for run sitemap creation
17,059
public function appendToFile ( $ content ) { $ result = @ fwrite ( $ this -> _file , $ content ) ; if ( $ result === false ) { throw new Exception ( "I'm can not wrtite to file" ) ; } return $ result ; }
Append to opened file new content
17,060
public function getModelsClasses ( $ modelsPath , $ modelsNamespace ) { $ path = Yii :: getAlias ( $ modelsPath ) ; $ files = @ scandir ( $ path ) ; if ( $ files === false ) { throw new InvalidConfigException ( 'Path to sitemap models "' . $ modelsPath . '"(' . $ path . ') is incorrect' ) ; } $ buffer = [ ] ; foreach (...
Get list of sitemap model instancies
17,061
public function handleModels ( array $ models ) { $ builder = $ this -> builder ; $ builder -> start ( ) ; foreach ( $ models as $ model ) { $ languages = ( array ) ( isset ( $ model -> sitemapLanguages ) ? $ model -> sitemapLanguages : Yii :: $ app -> language ) ; if ( count ( $ languages ) > 1 ) { foreach ( $ languag...
Start sitemap generate
17,062
public function handleModel ( Basic $ model , $ lang = null ) { $ items = $ model -> getSitemapItems ( $ lang ) ; if ( is_array ( $ items ) ) { foreach ( $ items as $ item ) { $ this -> handleItem ( $ item , $ lang ) ; } } $ query = $ model -> getSitemapItemsQuery ( $ lang ) ; if ( $ query instanceof \ yii \ db \ Query...
Handle all model content rows
17,063
public function handleItem ( $ item , $ lang ) { if ( is_array ( $ item ) ) { $ item = new SitemapArrayItem ( $ item ) ; $ loc = $ item -> getSitemapLoc ( ) ; if ( empty ( $ loc ) ) { $ this -> printMessage ( 'Warning: item "' . var_export ( $ item -> item , true ) . '" does not have a "loc" value' ) ; return false ; }...
Handle sitemap item
17,064
public static function getModelBatchSize ( Basic $ model , $ defaultValue = 10 ) { return isset ( $ model -> sitemapBatchSize ) ? $ model -> sitemapBatchSize : $ defaultValue ; }
Get model sitemapBatchSize attribute
17,065
public function printMessage ( $ text , $ fg = Console :: FG_YELLOW , $ bg = Console :: BG_BLACK ) { if ( Yii :: $ app instanceof \ yii \ console \ Application && Yii :: $ app -> controller -> interactive ) { Yii :: $ app -> controller -> stdout ( $ text . PHP_EOL , $ fg , $ bg ) ; } }
Show error in console mode
17,066
public static function setLanguage ( $ lang ) { static :: $ _appLanguage = Yii :: $ app -> language ; Yii :: $ app -> language = $ lang ; }
Set new app language and save original language for future restore
17,067
public function getEndpoint ( ) { $ endpoint = $ this -> getTestMode ( ) ? $ this -> testEndpoint : $ this -> liveEndpoint ; return $ endpoint . $ this -> getAccountNumber ( ) . '/rs/authService' ; }
Build endpoint .
17,068
public function isSuccessful ( ) { $ hashSecretWord = $ this -> data [ 'secretWord' ] ; $ hashSid = $ this -> data [ 'accountNumber' ] ; $ hashOrder = $ this -> data [ 'sale_id' ] ; $ hashInvoice = $ this -> data [ 'invoice_id' ] ; $ StringToHash = strtoupper ( md5 ( $ hashOrder . $ hashSid . $ hashInvoice . $ hashSecr...
Is the notification harsh correct after validation?
17,069
private function addServiceSection ( ArrayNodeDefinition $ node ) { $ node -> children ( ) -> arrayNode ( 'service' ) -> addDefaultsIfNotSet ( ) -> children ( ) -> scalarNode ( 'class' ) -> defaultValue ( Service \ Queue :: class ) -> cannotBeEmpty ( ) -> end ( ) -> scalarNode ( 'alias' ) -> defaultValue ( 'queue' ) ->...
Adds the sb_queue . service configuration .
17,070
private function addStoragesSection ( ArrayNodeDefinition $ node ) { $ node -> children ( ) -> arrayNode ( 'storages' ) -> addDefaultChildrenIfNoneSet ( 'redis' ) -> requiresAtLeastOneElement ( ) -> useAttributeAsKey ( 'redis' ) -> prototype ( 'array' ) -> children ( ) -> scalarNode ( 'class' ) -> defaultValue ( Servic...
Adds the sb_queue . storages configuration .
17,071
protected function formatTimezone ( $ timezone , $ continent ) { $ time = new DateTime ( null , new DateTimeZone ( $ timezone ) ) ; $ offset = $ time -> format ( 'P' ) ; $ offset = str_replace ( '-' , ' − ' , $ offset ) ; $ offset = str_replace ( '+' , ' + ' , $ offset ) ; $ timezone = substr ( $ timezone , ...
Format to display timezones
17,072
public function create ( $ name , $ selected = '' , $ attr = '' ) { $ attrSet = null ; if ( ! empty ( $ attr ) ) { if ( is_array ( $ attr ) ) { foreach ( $ attr as $ attr_name => $ attr_value ) { $ attrSet .= ' ' . $ attr_name . '="' . $ attr_value . '"' ; } } else { $ attrSet = ' ' . $ attr ; } } $ listbox = '<select ...
Create a GMT timezone select element for form
17,073
public function toArray ( ) { $ list = [ ] ; foreach ( $ this -> popularTimezones as $ key => $ value ) { $ list [ 'General' ] [ $ key ] = $ value ; } foreach ( $ this -> continents as $ continent => $ mask ) { $ timezones = DateTimeZone :: listIdentifiers ( $ mask ) ; foreach ( $ timezones as $ timezone ) { $ list [ $...
Create a timezone array
17,074
public function route ( $ route , $ title , $ parameters = array ( ) , $ order = null , $ attributes = array ( ) ) { if ( func_num_args ( ) == 4 ) { $ arguments = func_get_args ( ) ; return $ this -> add ( [ 'route' => [ array_get ( $ arguments , 0 ) , array_get ( $ arguments , 2 ) ] , 'title' => array_get ( $ argument...
Register new menu item using registered route .
17,075
public function route ( $ route , $ title , $ parameters = array ( ) , $ order = 0 , $ attributes = array ( ) ) { if ( func_num_args ( ) == 4 ) { $ arguments = func_get_args ( ) ; return $ this -> add ( [ 'route' => [ array_get ( $ arguments , 0 ) , array_get ( $ arguments , 2 ) ] , 'title' => array_get ( $ arguments ,...
Create new menu item and set the action to route .
17,076
public function url ( $ url , $ title , $ order = 0 , $ attributes = array ( ) ) { if ( func_num_args ( ) == 3 ) { $ arguments = func_get_args ( ) ; return $ this -> add ( [ 'url' => array_get ( $ arguments , 0 ) , 'title' => array_get ( $ arguments , 1 ) , 'attributes' => array_get ( $ arguments , 2 ) ] ) ; } return $...
Create new menu item and set the action to url .
17,077
public function getChilds ( ) { if ( config ( 'menus.ordering' ) ) { return collect ( $ this -> childs ) -> sortBy ( function ( $ child ) { return $ child -> order ; } ) -> all ( ) ; } return $ this -> childs ; }
Get childs .
17,078
private function _pdoTransactionsSupported ( ) { if ( ! is_null ( $ this -> _pdoTransactionsSupport ) ) { return $ this -> _pdoTransactionsSupport ; } try { $ supported = true ; parent :: beginTransaction ( ) ; } catch ( \ PDOException $ e ) { $ supported = false ; } if ( $ supported ) { parent :: commit ( ) ; } return...
Gets support for native transactions
17,079
function close ( ) { if ( $ this -> stream !== null && $ this -> stream !== false ) { return imap_close ( $ this -> stream ) ; } }
close the server stream
17,080
function connect ( ) { if ( $ this -> mailbox !== null && $ this -> username !== null && $ this -> password !== null ) { if ( $ this -> stream = imap_open ( $ this -> mailbox , $ this -> username , $ this -> password ) ) { return true ; } else { throw new Exception ( sprintf ( "Invalid IMAP stream (mailbox: %s, usernam...
open the server stream
17,081
function move ( $ uid , $ folder , $ expunge = true ) { if ( $ this -> stream !== null && $ this -> stream !== false ) { $ tries = 0 ; while ( $ tries ++ < 3 ) { if ( imap_mail_move ( $ this -> stream , $ uid , $ folder , CP_UID ) ) { if ( $ expunge ) { imap_expunge ( $ this -> stream ) ; } return true ; } else { sleep...
move the message to a folder
17,082
function get_message ( $ uid , $ raw = null ) { if ( $ this -> stream !== null && $ this -> stream !== false ) { if ( $ raw === null ) { $ raw = $ this -> options [ 'raw' ] ; } $ raw_header = imap_fetchheader ( $ this -> stream , $ uid , FT_UID ) ; $ raw_body = imap_body ( $ this -> stream , $ uid , FT_UID ) ; $ raw_me...
get a specific message
17,083
private function prepareFileContent ( $ fileContent ) { $ fileContent = preg_replace ( "#(.*)//(.*)#" , " " , $ fileContent ) ; $ fileContent = preg_replace ( "#/\*(.*)\*?/#" , "" , $ fileContent ) ; $ fileContent = preg_replace ( "/\n*/" , "" , $ fileContent ) ; $ fileContent = str_replace ( "<?php" , "<?php\n\n" , $ ...
Prepare file content for parsing .
17,084
private function extractController ( $ path , $ controller , $ initialSpace = '' ) { $ class = new ReflectionClass ( $ this -> controllersNamespace . '\\' . $ controller ) ; $ methods = $ class -> getMethods ( ReflectionMethod :: IS_PUBLIC ) ; $ routables = array_filter ( $ methods , function ( $ method ) { return $ me...
Extract routes from a given controller
17,085
private function getWildcards ( ReflectionMethod $ routable ) { $ output = '' ; foreach ( $ routable -> getParameters ( ) as $ parameter ) { if ( $ parameter -> hasType ( ) ) { continue ; } $ wildCard = Str :: snake ( $ parameter -> getName ( ) ) . ( $ parameter -> isDefaultValueAvailable ( ) ? '?' : '' ) ; $ output .=...
Get the wildcards string for the route URI .
17,086
public function getSummaryThumbnail ( ) { $ data = [ ] ; if ( $ this -> File ( ) && $ this -> File ( ) -> exists ( ) ) { if ( $ this -> File ( ) -> getIsImage ( ) ) { if ( $ this -> File ( ) -> getOrientation ( ) === Image_Backend :: ORIENTATION_PORTRAIT ) { $ data [ 'Image' ] = $ this -> File ( ) -> ScaleWidth ( 36 ) ...
Return a thumbnail of the file if it s an image . Used in GridField preview summaries .
17,087
public function templateIndexVars ( $ newIndexFile ) { File :: put ( $ newIndexFile , str_replace ( '%%formHeadingHtml%%' , $ this -> formHeadingHtml , File :: get ( $ newIndexFile ) ) ) ; File :: put ( $ newIndexFile , str_replace ( '%%formBodyHtml%%' , $ this -> formBodyHtml , File :: get ( $ newIndexFile ) ) ) ; Fil...
Update values between %% with real values in index view .
17,088
public function templateCreateVars ( $ newCreateFile ) { File :: put ( $ newCreateFile , str_replace ( '%%crudName%%' , $ this -> crudName , File :: get ( $ newCreateFile ) ) ) ; File :: put ( $ newCreateFile , str_replace ( '%%modelName%%' , $ this -> modelName , File :: get ( $ newCreateFile ) ) ) ; File :: put ( $ n...
Update values between %% with real values in create view .
17,089
public function templateEditVars ( $ newEditFile ) { File :: put ( $ newEditFile , str_replace ( '%%crudName%%' , $ this -> crudName , File :: get ( $ newEditFile ) ) ) ; File :: put ( $ newEditFile , str_replace ( '%%crudNameSingular%%' , $ this -> crudNameSingular , File :: get ( $ newEditFile ) ) ) ; File :: put ( $...
Update values between %% with real values in edit view .
17,090
public function templateShowVars ( $ newShowFile ) { File :: put ( $ newShowFile , str_replace ( '%%formHeadingHtml%%' , $ this -> formHeadingHtml , File :: get ( $ newShowFile ) ) ) ; File :: put ( $ newShowFile , str_replace ( '%%formBodyHtml%%' , $ this -> formBodyHtmlForShowView , File :: get ( $ newShowFile ) ) ) ...
Update values between %% with real values in show view .
17,091
protected function createField ( $ item ) { switch ( $ this -> typeLookup [ $ item [ 'type' ] ] ) { case 'password' : return $ this -> createPasswordField ( $ item ) ; break ; case 'datetime-local' : case 'time' : return $ this -> createInputField ( $ item ) ; break ; case 'radio' : return $ this -> createRadioField ( ...
Form field generator .
17,092
protected function createFormField ( $ item ) { $ required = ( $ item [ 'required' ] === true ) ? ", 'required' => 'required'" : "" ; return $ this -> wrapField ( $ item , "{!! Form::" . $ this -> typeLookup [ $ item [ 'type' ] ] . "('" . $ item [ 'name' ] . "', null, ['class' => 'form-control'$required]) !!}" ) ; }
Create a specific field using the form helper .
17,093
protected function createInputField ( $ item ) { $ required = ( $ item [ 'required' ] === true ) ? ", 'required' => 'required'" : "" ; return $ this -> wrapField ( $ item , "{!! Form::input('" . $ this -> typeLookup [ $ item [ 'type' ] ] . "', '" . $ item [ 'name' ] . "', null, ['class' => 'form-control'$required]) !!}...
Create a generic input field using the form helper .
17,094
public function setValue ( $ value , $ data = null ) { $ this -> parsedValue = null ; return parent :: setValue ( $ value , $ data ) ; }
Reset the cached parsed value when setting a new value
17,095
public function setShowLinkText ( $ showLinkText ) { $ this -> showLinkText = ( bool ) $ showLinkText ; $ this -> setAttribute ( 'data-showlinktext' , ( int ) $ this -> showLinkText ) ; return $ this ; }
Set whether to display the link text field
17,096
public function getSummary ( ) { if ( $ this -> File ( ) && $ this -> File ( ) -> exists ( ) ) { return $ this -> getSummaryThumbnail ( ) . $ this -> dbObject ( 'Content' ) -> Summary ( 20 ) ; } return '' ; }
Add the banner content instead of the image title
17,097
public function setOptions ( $ options = [ ] , $ update = false ) { if ( ! $ update ) { $ defaults = $ this -> setOptionDefaults ( ) ; } else { $ defaults = $ this -> getOptions ( ) ; } $ options = array_intersect_key ( array_filter ( $ options ) , $ defaults ) ; $ options = array_merge ( $ options , array_diff_key ( $...
Set Notification options to instance .
17,098
public function add ( $ content = NULL , $ options = [ ] ) { if ( ! empty ( $ content ) ) $ options [ 'content' ] = $ content ; $ this -> notifications -> push ( new Notification ( $ options ) ) ; return $ this -> flash ( ) ; }
Add a notification to our collection .
17,099
public function typeShorthand ( $ type , $ params = [ ] ) { $ options = [ ] ; $ content = NULL ; $ count = count ( $ params ) ; if ( $ count < 1 ) { $ this -> updateLastNotification ( [ 'type' => $ type ] ) ; } elseif ( $ count == 1 ) { if ( is_array ( $ params [ 0 ] ) ) { $ options = $ params [ 0 ] ; } else { $ conten...
Set priority property for chaining notification