idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
16,600
public function getExcelActions ( ) { if ( null === $ this -> excelActions ) { $ this -> excelActions = array ( ) ; $ this -> fillExportActions ( ) ; } return $ this -> excelActions ; }
Return a list of actions from excel . export
16,601
public function getAdmingeneratorConfig ( $ name ) { $ search_in = $ this -> bundleConfig ; $ path = explode ( '.' , $ name ) ; foreach ( $ path as $ key ) { if ( ! array_key_exists ( $ key , $ search_in ) ) { throw new \ InvalidArgumentException ( 'Unknown parameter "admingenerator.' . $ name . '".' ) ; } $ search_in ...
Returns admingenerator parameter
16,602
private function injectFormThemeConfiguration ( ContainerBuilder $ container ) { if ( ( $ twigConfiguration = $ container -> getParameter ( 'admingenerator.twig' ) ) !== false ) { $ resources = $ container -> getParameter ( 'twig.form.resources' ) ; $ alreadyIn = in_array ( 'bootstrap_3_layout.html.twig' , $ resources ...
Check if we need to automatically add form theme from admingen in the application configuration .
16,603
protected function addDropdown ( ItemInterface $ menu , $ label , $ caret = true ) { $ item = $ this -> addLinkURI ( $ menu , $ label , '#' ) ; $ item -> setChildrenAttributes ( array ( 'class' => 'treeview-menu' ) ) ; $ item -> setAttributes ( array ( 'class' => 'treeview' ) ) ; $ item -> setExtra ( 'caret' , $ caret ...
Creates dropdown menu element and adds it to menu
16,604
protected function propelInit ( ) { if ( ! \ Propel :: isInit ( ) ) { \ Propel :: setConfiguration ( $ this -> container -> get ( 'propel.configuration' ) ) ; \ Propel :: initialize ( ) ; } }
Force Propel boot before cache warmup
16,605
private function registerFormsServicesFromGenerator ( array $ generatorParameters , array $ builders , ContainerBuilder $ container ) { $ modelParts = explode ( '\\' , $ generatorParameters [ 'model' ] ) ; $ model = strtolower ( array_pop ( $ modelParts ) ) ; $ fullQualifiedNormalizedModelName = strtolower ( str_replac...
Register forms as services for a generator . Register only generated forms based on defined builders .
16,606
protected function checkResponse ( ResponseInterface $ response , $ data ) { if ( $ response -> getStatusCode ( ) >= 400 ) { $ errorMessage = '' ; if ( ! empty ( $ data [ 'errors' ] ) ) { foreach ( $ data [ 'errors' ] as $ error ) { if ( ! empty ( $ errorMessage ) ) { $ errorMessage .= ' , ' ; } $ errorMessage .= implo...
Checks Fitbit API response for errors .
16,607
protected function getAuthorizationParameters ( array $ options ) { $ params = parent :: getAuthorizationParameters ( $ options ) ; unset ( $ params [ 'approval_prompt' ] ) ; if ( ! empty ( $ options [ 'prompt' ] ) ) { $ params [ 'prompt' ] = $ options [ 'prompt' ] ; } return $ params ; }
Returns authorization parameters based on provided options . Fitbit does not use the approval_prompt param and here we remove it .
16,608
protected function getAccessTokenOptions ( array $ params ) { $ options = parent :: getAccessTokenOptions ( $ params ) ; $ options [ 'headers' ] [ 'Authorization' ] = 'Basic ' . base64_encode ( $ this -> clientId . ':' . $ this -> clientSecret ) ; return $ options ; }
Builds request options used for requesting an access token .
16,609
public function revoke ( AccessToken $ accessToken ) { $ options = $ this -> getAccessTokenOptions ( [ ] ) ; $ uri = $ this -> appendQuery ( self :: BASE_FITBIT_API_URL . '/oauth2/revoke' , $ this -> buildQueryString ( [ 'token' => $ accessToken -> getToken ( ) ] ) ) ; $ request = $ this -> getRequest ( self :: METHOD_...
Revoke access for the given token .
16,610
protected function renderHiddenReferrerFields ( ) { $ tagBuilder = new TagBuilder ( 'input' ) ; $ tagBuilder -> addAttribute ( 'type' , 'hidden' ) ; $ tagBuilder -> addAttribute ( 'name' , $ this -> prefixFieldName ( '__state' ) ) ; $ formRuntime = $ this -> arguments [ 'object' ] ; $ tagBuilder -> addAttribute ( 'valu...
Renders hidden form fields for referrer information about the current request .
16,611
protected function getFormActionUri ( ) { $ actionRequest = $ this -> controllerContext -> getRequest ( ) ; $ uri = $ actionRequest -> getHttpRequest ( ) -> getUri ( ) ; if ( $ this -> hasArgument ( 'section' ) ) { $ uri = preg_replace ( '/#.*$/' , '' , $ uri ) . '#' . $ this -> arguments [ 'section' ] ; } return ( str...
Overrides the forms action URI to be the same as the currently requested URI
16,612
public function listForms ( ) { $ this -> assertSavePathIsValid ( ) ; $ forms = [ ] ; $ directoryIterator = new \ DirectoryIterator ( $ this -> savePath ) ; foreach ( $ directoryIterator as $ fileObject ) { if ( ! $ fileObject -> isFile ( ) ) { continue ; } $ fileInfo = pathinfo ( $ fileObject -> getFilename ( ) ) ; if...
List all form definitions which can be loaded through this form persistence manager .
16,613
protected function assertSavePathIsValid ( ) { if ( $ this -> savePath === null || ! is_dir ( $ this -> savePath ) ) { throw new PersistenceManagerException ( sprintf ( 'The savePath "%s" is not usable.' , $ this -> savePath ) , 1499347363 ) ; } }
Check if the save path is set and points to a directory .
16,614
public function onSubmit ( FormRuntime $ formRuntime , & $ elementValue ) { $ imageTypeValidator = new ImageTypeValidator ( array ( 'allowedTypes' => $ this -> properties [ 'allowedTypes' ] ) ) ; $ this -> addValidator ( $ imageTypeValidator ) ; }
Add ImageTypeValidator just before submitting so that the allowedTypes can be changed at runtime
16,615
protected function getUploadedResource ( ) { if ( $ this -> getMappingResultsForProperty ( ) -> hasErrors ( ) ) { return null ; } $ resourceObject = $ this -> getPropertyValue ( ) ; if ( $ resourceObject instanceof PersistentResource ) { return $ resourceObject ; } return $ this -> propertyMapper -> convert ( $ this ->...
Returns a previously uploaded resource . If errors occurred during property mapping for this property NULL is returned
16,616
protected function addRenderable ( RenderableInterface $ renderable ) { if ( $ renderable -> getParentRenderable ( ) !== null ) { throw new FormDefinitionConsistencyException ( sprintf ( 'The renderable with identifier "%s" is already added to another element (element identifier: "%s").' , $ renderable -> getIdentifier...
Add a renderable to the list of child renderables .
16,617
public function getRenderablesRecursively ( ) { $ renderables = [ ] ; foreach ( $ this -> renderables as $ renderable ) { $ renderables [ ] = $ renderable ; if ( $ renderable instanceof CompositeRenderableInterface ) { $ renderables = array_merge ( $ renderables , $ renderable -> getRenderablesRecursively ( ) ) ; } } r...
Returns all RenderableInterface instances of this composite renderable recursively
16,618
protected function removeRenderable ( RenderableInterface $ renderableToRemove ) { if ( $ renderableToRemove -> getParentRenderable ( ) !== $ this ) { throw new FormDefinitionConsistencyException ( 'The renderable to be removed must be part of the calling parent renderable.' , 1326090127 ) ; } $ updatedRenderables = [ ...
Remove a renderable from this renderable .
16,619
public function registerInFormIfPossible ( ) { parent :: registerInFormIfPossible ( ) ; foreach ( $ this -> renderables as $ renderable ) { if ( $ renderable instanceof AbstractRenderable ) { $ renderable -> registerInFormIfPossible ( ) ; } } }
Register this element at the parent form if there is a connection to the parent form .
16,620
public function setParentRenderable ( Renderable \ CompositeRenderableInterface $ parentRenderable ) { if ( ! ( $ parentRenderable instanceof FormDefinition ) ) { throw new Exception ( sprintf ( 'The specified parentRenderable must be a FormDefinition, got "%s"' , is_object ( $ parentRenderable ) ? get_class ( $ parent...
Set the parent renderable
16,621
public function render ( ) { $ name = $ this -> getName ( ) ; $ this -> registerFieldNameForFormTokenGeneration ( $ name ) ; $ this -> tag -> addAttribute ( 'name' , $ name . '[hour]' ) ; $ date = $ this -> getSelectedDate ( ) ; $ this -> setErrorClassAttribute ( ) ; $ content = '' ; $ content .= $ this -> buildHourSel...
Renders the select fields for hour & minute
16,622
protected function userWentBackToPreviousStep ( ) { return ! $ this -> isAfterLastPage ( ) && ! $ this -> isFirstRequest ( ) && $ this -> currentPage -> getIndex ( ) < $ this -> lastDisplayedPage -> getIndex ( ) ; }
returns TRUE if the user went back to any previous step in the form .
16,623
public function render ( ) { if ( $ this -> isAfterLastPage ( ) ) { $ this -> invokeFinishers ( ) ; $ parentResponse = $ this -> response -> getParentResponse ( ) ; if ( $ parentResponse !== null ) { foreach ( $ this -> response -> getHeaders ( ) -> getAll ( ) as $ key => $ value ) { $ parentResponse -> getHeaders ( ) ...
Render this form .
16,624
protected function invokeFinishers ( ) { $ finisherContext = new FinisherContext ( $ this ) ; foreach ( $ this -> formDefinition -> getFinishers ( ) as $ finisher ) { $ finisher -> execute ( $ finisherContext ) ; if ( $ finisherContext -> isCancelled ( ) ) { break ; } } }
Executes all finishers of this form
16,625
public function getPreviousPage ( ) { $ previousPageIndex = $ this -> currentPage -> getIndex ( ) - 1 ; if ( ! $ this -> formDefinition -> hasPageWithIndex ( $ previousPageIndex ) ) { return null ; } return $ this -> formDefinition -> getPageByIndex ( $ previousPageIndex ) ; }
Returns the previous page of the currently selected one or NULL if there is no previous page
16,626
public function getNextPage ( ) { $ nextPageIndex = $ this -> currentPage -> getIndex ( ) + 1 ; if ( ! $ this -> formDefinition -> hasPageWithIndex ( $ nextPageIndex ) ) { return null ; } return $ this -> formDefinition -> getPageByIndex ( $ nextPageIndex ) ; }
Returns the next page of the currently selected one or NULL if there is no next page
16,627
protected function getElementValue ( $ identifier ) { $ formValue = $ this -> formState -> getFormValue ( $ identifier ) ; if ( $ formValue !== null ) { return $ formValue ; } return $ this -> formDefinition -> getElementDefaultValueByIdentifier ( $ identifier ) ; }
Returns the value of the specified element
16,628
public function createValidator ( $ validatorIdentifier , array $ options = [ ] ) { $ validatorPresets = $ this -> getRootForm ( ) -> getValidatorPresets ( ) ; if ( isset ( $ validatorPresets [ $ validatorIdentifier ] ) && is_array ( $ validatorPresets [ $ validatorIdentifier ] ) && isset ( $ validatorPresets [ $ valid...
Create a validator for the element
16,629
public function addValidator ( ValidatorInterface $ validator ) { $ formDefinition = $ this -> getRootForm ( ) ; $ formDefinition -> getProcessingRule ( $ this -> getIdentifier ( ) ) -> addValidator ( $ validator ) ; }
Add a validator to the element
16,630
public function setDataType ( $ dataType ) { $ formDefinition = $ this -> getRootForm ( ) ; $ formDefinition -> getProcessingRule ( $ this -> getIdentifier ( ) ) -> setDataType ( $ dataType ) ; }
Set the datatype
16,631
public function getRootForm ( ) { $ rootRenderable = $ this -> parentRenderable ; while ( $ rootRenderable !== null && ! ( $ rootRenderable instanceof FormDefinition ) ) { $ rootRenderable = $ rootRenderable -> getParentRenderable ( ) ; } if ( $ rootRenderable === null ) { throw new FormDefinitionConsistencyException (...
Get the root form this element belongs to
16,632
public function onRemoveFromParentRenderable ( ) { try { $ rootForm = $ this -> getRootForm ( ) ; $ rootForm -> unregisterRenderable ( $ this ) ; } catch ( FormDefinitionConsistencyException $ exception ) { } $ this -> parentRenderable = null ; }
Triggered when the renderable is removed from it s parent
16,633
public function onSubmit ( FormRuntime $ formRuntime , & $ elementValue ) { $ fileTypeValidator = new FileTypeValidator ( array ( 'allowedExtensions' => $ this -> properties [ 'allowedExtensions' ] ) ) ; $ this -> addValidator ( $ fileTypeValidator ) ; }
Add FileTypeValidator just before submitting so that the allowedExtension can be changed at runtime
16,634
protected function initializeFromFormDefaults ( ) { $ typeDefinition = $ this -> formFieldTypeManager -> getMergedTypeDefinition ( $ this -> type ) ; $ this -> setOptions ( $ typeDefinition ) ; }
Initialize the form defaults of the current type
16,635
public function getPageByIndex ( $ index ) { if ( ! $ this -> hasPageWithIndex ( $ index ) ) { throw new Exception ( sprintf ( 'There is no page with an index of %d' , $ index ) , 1329233627 ) ; } return $ this -> renderables [ $ index ] ; }
Get the page with the passed index . The first page has index zero .
16,636
public function registerRenderable ( Renderable \ RenderableInterface $ renderable ) { if ( $ renderable instanceof FormElementInterface ) { if ( isset ( $ this -> elementsByIdentifier [ $ renderable -> getIdentifier ( ) ] ) ) { throw new Exception \ DuplicateFormElementException ( sprintf ( 'A form element with identi...
Add an element to the ElementsByIdentifier Cache .
16,637
public function unregisterRenderable ( Renderable \ RenderableInterface $ renderable ) { if ( $ renderable instanceof FormElementInterface ) { unset ( $ this -> elementsByIdentifier [ $ renderable -> getIdentifier ( ) ] ) ; } }
Remove an element from the ElementsByIdentifier cache
16,638
public function getElementByIdentifier ( $ elementIdentifier ) { return isset ( $ this -> elementsByIdentifier [ $ elementIdentifier ] ) ? $ this -> elementsByIdentifier [ $ elementIdentifier ] : null ; }
Get a Form Element by its identifier
16,639
public function addElementDefaultValue ( $ elementIdentifier , $ defaultValue ) { $ this -> elementDefaultValues = Arrays :: setValueByPath ( $ this -> elementDefaultValues , $ elementIdentifier , $ defaultValue ) ; }
Sets the default value of a form element
16,640
public function build ( array $ configuration , $ presetName ) { $ formDefaults = $ this -> getPresetConfiguration ( $ presetName ) ; $ form = isset ( $ configuration [ 'type' ] ) ? new FormDefinition ( $ configuration [ 'identifier' ] , $ formDefaults , $ configuration [ 'type' ] ) : new FormDefinition ( $ configurati...
Build a form definition depending on some configuration and a Preset Name .
16,641
public function getUniqueIdentifier ( ) { $ formDefinition = $ this -> getRootForm ( ) ; $ uniqueIdentifier = sprintf ( '%s-%s' , $ formDefinition -> getIdentifier ( ) , $ this -> identifier ) ; $ uniqueIdentifier = preg_replace ( '/[^a-zA-Z0-9-_]/' , '_' , $ uniqueIdentifier ) ; return lcfirst ( $ uniqueIdentifier ) ;...
Get the global unique identifier of the element
16,642
public function setDefaultValue ( $ defaultValue ) { $ formDefinition = $ this -> getRootForm ( ) ; $ formDefinition -> addElementDefaultValue ( $ this -> identifier , $ defaultValue ) ; }
Set the default value of the element
16,643
protected function getUploadedImage ( ) { if ( $ this -> getMappingResultsForProperty ( ) -> hasErrors ( ) ) { return null ; } $ image = $ this -> getPropertyValue ( ) ; if ( $ image instanceof Image ) { return $ image ; } return $ this -> propertyMapper -> convert ( $ this -> getValueAttribute ( ) , Image :: class ) ;...
Returns a previously uploaded image . If errors occurred during property mapping for this property NULL is returned
16,644
public function renameTranslationPackage ( array & $ preset ) { foreach ( $ preset as $ key => $ value ) { if ( is_array ( $ value ) ) { if ( isset ( $ value [ 'renderingOptions' ] [ 'translationPackage' ] ) ) { $ value [ 'renderingOptions' ] [ 'validationErrorTranslationPackage' ] = $ value [ 'renderingOptions' ] [ 't...
Recurse into the given preset and rename translationPackage to validationErrorTranslationPackage
16,645
public function render ( $ dateFormat = 'Y-m-d' , $ enableDatePicker = true ) { $ name = $ this -> getName ( ) ; $ this -> registerFieldNameForFormTokenGeneration ( $ name ) ; $ this -> tag -> addAttribute ( 'type' , 'date' ) ; $ this -> tag -> addAttribute ( 'name' , $ name . '[date]' ) ; if ( $ enableDatePicker ) { $...
Renders the text field hidden field and required javascript
16,646
function getPath ( \ DOMDocument $ document ) { $ name = $ document -> documentElement -> localName ; if ( empty ( $ this -> version ) ) { $ this -> loadVersion ( $ document ) ; } $ path = $ this -> getFullPath ( $ name ) ; return $ path ; }
Get Path XSD .
16,647
public function getVersion ( \ DOMDocument $ document ) { if ( empty ( $ document -> documentElement ) ) { return '' ; } $ xpath = $ this -> getXpath ( $ document ) ; $ this -> setNs ( $ document ) ; $ xpath -> registerNamespace ( 'cbc' , self :: CBC_NS ) ; return $ this -> getSingleValue ( $ xpath , 'cbc:UBLVersionID'...
UBL Version resolver .
16,648
public function setColor ( $ red , $ green , $ blue ) { $ this -> red = $ red ; $ this -> green = $ green ; $ this -> blue = $ blue ; return $ this ; }
Sets RGB color for text .
16,649
public function wrappText ( ) { $ wrapp = $ this -> getWrappedText ( $ this -> size , $ this -> angle , $ this -> fontface , $ this -> string , $ this -> width ) ; return $ wrapp ; }
Wrapps the text .
16,650
public function getWrappedText ( $ size , $ angle , $ fontface , $ string , $ width = 100 ) { $ str = '' ; $ words = explode ( ' ' , $ string ) ; foreach ( $ words as $ word ) { $ testStr = $ str . ' ' . $ word ; $ box = imagettfbbox ( $ size , $ angle , $ fontface , $ testStr ) ; if ( $ box [ 2 ] > $ width ) { $ str ....
Gets wrapped text .
16,651
private function getBoundingBox ( $ fontSize , $ fontAngle , $ fontFile , $ text ) { $ box = imagettfbbox ( $ fontSize , $ fontAngle , $ fontFile , $ text ) ; if ( ! $ box ) { return false ; } $ minX = min ( [ $ box [ 0 ] , $ box [ 2 ] , $ box [ 4 ] , $ box [ 6 ] ] ) ; $ maxX = max ( [ $ box [ 0 ] , $ box [ 2 ] , $ box...
Calculates bounding box of text using the TrueType font . Returns an array with left top width and height values .
16,652
public function from ( $ element = null ) { if ( ! empty ( $ element ) && $ element instanceof Image ) { foreach ( get_object_vars ( $ element ) as $ key => $ value ) { $ this -> $ key = $ value ; } return $ this ; } }
Loads an image from Image or Figure class .
16,653
public function load ( $ src ) { if ( empty ( $ src ) ) { return $ this ; } if ( $ this -> isImageStringByString ( $ src ) ) { $ this -> loadImageFromString ( $ src ) ; } elseif ( filter_var ( $ src , FILTER_VALIDATE_URL ) ) { $ this -> loadImageFromURL ( $ src ) ; } elseif ( is_file ( $ src ) ) { $ this -> loadImageFr...
Loads an image from a local path external url or image string .
16,654
private function loadImageFromURL ( $ url ) { $ image = $ this -> fetchImageContentFromURL ( $ url ) ; if ( empty ( $ image ) ) { return ; } if ( Utils :: isJPGResource ( $ image ) ) { $ this -> filename = $ url ; $ this -> extension = 'jpg' ; $ this -> type = IMAGETYPE_JPEG ; } if ( Utils :: isPNGResource ( $ image ) ...
Load an image from URL .
16,655
private function fetchImageContentFromURL ( $ url ) { $ data = null ; if ( $ stream = fopen ( $ url , 'r' ) ) { $ data = stream_get_contents ( $ stream ) ; fclose ( $ stream ) ; } return $ data ; }
Fetch an image string content from URL .
16,656
private function loadImageFromString ( $ imagestring ) { if ( Utils :: isJPGResource ( $ imagestring ) ) { $ this -> extension = 'jpg' ; $ this -> type = IMAGETYPE_JPEG ; } if ( Utils :: isPNGResource ( $ imagestring ) ) { $ this -> extension = 'png' ; $ this -> type = IMAGETYPE_PNG ; } $ this -> from = 'imagestring' ;...
Load an image from image string .
16,657
private function loadImageFromFile ( $ filepath ) { $ this -> from = 'local' ; $ this -> filename = $ filepath ; if ( ! is_readable ( $ filepath ) ) { return ; } $ image = null ; $ extension = '' ; list ( $ width , $ height , $ imageType ) = getimagesize ( $ filepath ) ; switch ( $ imageType ) { case IMAGETYPE_GIF : $ ...
Load an image file from path .
16,658
public function toJPG ( ) { $ this -> extension = 'jpg' ; $ this -> type = IMAGETYPE_JPEG ; $ this -> mimetype = Utils :: getMimetypeByImageType ( IMAGETYPE_JPEG ) ; return $ this ; }
Changes output format to JPG .
16,659
public function toPNG ( ) { $ this -> extension = 'png' ; $ this -> type = IMAGETYPE_PNG ; $ this -> mimetype = Utils :: getMimetypeByImageType ( IMAGETYPE_PNG ) ; return $ this ; }
Changes output format to PNG .
16,660
public function toGIF ( ) { $ this -> extension = 'gif' ; $ this -> type = IMAGETYPE_GIF ; $ this -> mimetype = Utils :: getMimetypeByImageType ( IMAGETYPE_GIF ) ; return $ this ; }
Changes output format to GIF .
16,661
public function resizeToHeight ( $ height ) { $ width = $ this -> getPropWidth ( $ height ) ; $ this -> resize ( $ width , $ height ) ; return $ this ; }
Resize image proportionally basing on the height of the image .
16,662
public function resizeToWidth ( $ width ) { $ height = $ this -> getPropHeight ( $ width ) ; $ this -> resize ( $ width , $ height ) ; return $ this ; }
Resize image proportionally basing on the width of the image .
16,663
public function getPropWidth ( $ height ) { $ ratio = ( int ) $ height / $ this -> height ; return $ this -> width * $ ratio ; }
Gets proportional width of image from height value .
16,664
public function getPropHeight ( $ width ) { $ ratio = ( int ) $ width / $ this -> width ; return $ this -> height * $ ratio ; }
Gets proportional height of image from width value .
16,665
public function scale ( $ scale = 1 ) { if ( $ scale > 1 ) { $ scale = 1 ; } $ width = ( int ) $ this -> width * $ scale ; $ height = ( int ) $ this -> height * $ scale ; $ this -> resize ( $ width , $ height ) ; return $ this ; }
Scales the image .
16,666
public function rotate ( $ angle = 0 ) { if ( $ this -> resource ) { $ this -> resource = imagerotate ( $ this -> resource , $ angle , 0 ) ; } return $ this ; }
Rotate the image with a given angle .
16,667
public function centerCrop ( $ width , $ height ) { $ pwidth = $ this -> getPropWidth ( $ height ) ; $ pheight = $ this -> getPropHeight ( $ width ) ; if ( $ pwidth == $ width && $ pheight == $ height ) { $ this -> resizeToWidth ( $ width ) ; } else { if ( $ pheight > $ height ) { $ this -> resizeToWidth ( $ width ) ; ...
Cuts the image proportionally and centered .
16,668
public function crop ( $ width , $ height , $ x1 = 0 , $ y1 = 0 , $ dstX = 0 , $ dstY = 0 ) { $ this -> resize ( $ width , $ height , $ x1 , $ y1 , $ dstX , $ dstY , true ) ; return $ this ; }
Cuts part of image .
16,669
private function resize ( $ width , $ height , $ x1 = 0 , $ y1 = 0 , $ dstX = 0 , $ dstY = 0 , $ isCrop = false ) { if ( $ this -> resource && $ width > 0 && $ height > 0 ) { $ image = imagecreatetruecolor ( $ width , $ height ) ; if ( $ this -> isPNG ( ) ) { imagealphablending ( $ image , false ) ; imagesavealpha ( $ ...
Resizes the image .
16,670
public function render ( ) { $ image = null ; if ( $ this -> resource ) { ob_start ( ) ; $ this -> outputBufferByImage ( null , $ this -> quality ) ; $ string = ob_get_contents ( ) ; ob_end_clean ( ) ; if ( ! empty ( $ string ) ) { $ image = imagecreatefromstring ( $ string ) ; } } return $ image ; }
Render the image in - memory and return the resource .
16,671
private function outputBuffer ( $ filename = null , $ output = false ) { if ( ! $ this -> resource ) { return $ this ; } if ( $ output ) { $ filename = null ; } elseif ( empty ( $ filename ) && $ this -> isLocal ( ) ) { $ filename = $ this -> filename ; } elseif ( empty ( $ filename ) && $ this -> isExternal ( ) ) { $ ...
Output the image to either the browser or a file .
16,672
public function destroy ( ) { if ( $ this -> resource ) { imagedestroy ( $ this -> resource ) ; } $ this -> resource = null ; return $ this ; }
Destroys the current resource .
16,673
protected function addOpacityFilter ( ) { $ opacity = Utils :: fixPNGOpacity ( $ this -> opacity ) ; if ( $ opacity >= 0 && $ opacity < 127 ) { imagealphablending ( $ this -> resource , false ) ; imagefilter ( $ this -> resource , IMG_FILTER_COLORIZE , 0 , 0 , 0 , $ opacity ) ; } }
Add opacity filter to the current resource .
16,674
public function boot ( ) { $ this -> loadViewsFrom ( __DIR__ . '/resources/views' , 'notifications' ) ; if ( $ this -> app -> runningInConsole ( ) ) { $ this -> publishes ( [ __DIR__ . '/resources/views' => $ this -> app -> basePath ( ) . '/resources/views/vendor/notifications' , ] , 'laravel-notifications' ) ; } if ( ...
Boot the application services .
16,675
private function getAppVersion ( ) { $ version = $ this -> app -> version ( ) ; if ( substr ( $ version , 0 , 7 ) === 'Lumen (' ) { $ version = array_first ( explode ( ')' , str_replace ( 'Lumen (' , '' , $ version ) ) ) ; } return $ version ; }
Get the version number of the application .
16,676
protected function createBaseMigration ( ) { $ name = 'create_notifications_table' ; $ path = $ this -> laravel -> databasePath ( ) . '/migrations' ; return $ this -> laravel [ 'migration.creator' ] -> create ( $ name , $ path ) ; }
Create a base migration file for the notifications .
16,677
public function append ( $ elements ) { if ( ! empty ( $ elements ) ) { $ elements = is_array ( $ elements ) ? $ elements : [ $ elements ] ; foreach ( $ elements as $ element ) { if ( $ element instanceof Image || $ element instanceof Text ) { $ this -> elementList [ ] = $ element ; } } } return $ this ; }
Adds one or more elements to canvas .
16,678
public function draw ( ) { $ canvas = $ this -> resource ; if ( $ canvas ) { foreach ( $ this -> elementList as $ element ) { if ( $ element instanceof Image ) { $ this -> drawImage ( $ element , $ canvas ) ; } if ( $ element instanceof Text ) { $ this -> drawText ( $ element , $ canvas ) ; } } $ this -> resource = $ c...
Draws the canvas .
16,679
private function drawImage ( $ element , $ canvas ) { $ image = $ element -> getResource ( ) ; imagecopyresampled ( $ canvas , $ image , $ element -> getLeft ( ) , $ element -> getTop ( ) , $ element -> getBoxLeft ( ) , $ element -> getBoxTop ( ) , $ element -> getBoxWidth ( ) , $ element -> getBoxHeight ( ) , $ elemen...
Draw the an Image or Figure element .
16,680
private function drawText ( Text $ text , $ canvas ) { list ( $ red , $ green , $ blue ) = $ text -> getColor ( ) ; $ opacity = Utils :: fixPNGOpacity ( $ text -> getOpacity ( ) ) ; $ color = imagecolorallocatealpha ( $ canvas , $ red , $ green , $ blue , $ opacity < 127 ? $ opacity : null ) ; $ size = $ text -> getSiz...
Draw a Text element .
16,681
public function setSize ( $ width = 0 , $ height = 0 ) { if ( ! empty ( $ width ) && ! empty ( $ height ) ) { $ this -> width = $ this -> boxWidth = $ width ; $ this -> height = $ this -> boxHeight = $ height ; } return $ this ; }
Sets size to figure .
16,682
public function setBackgroundColor ( $ red , $ green , $ blue ) { $ this -> red = $ red ; $ this -> green = $ green ; $ this -> blue = $ blue ; return $ this ; }
Sets background color in RGB format .
16,683
public function create ( ) { $ this -> resource = imagecreatetruecolor ( $ this -> width , $ this -> height ) ; imagesavealpha ( $ this -> resource , true ) ; $ color = imagecolorallocatealpha ( $ this -> resource , $ this -> red , $ this -> green , $ this -> blue , null ) ; if ( $ this -> figureType == 'rectangle' ) {...
Creates the figure with alpha channel .
16,684
private function createRectangle ( $ color ) { imagefilledrectangle ( $ this -> resource , 0 , 0 , $ this -> width , $ this -> height , $ color ) ; }
Creates a filled rectangle .
16,685
private function createEllipse ( $ color ) { $ alpha = imagecolorallocatealpha ( $ this -> resource , 255 , 255 , 255 , 127 ) ; imagefill ( $ this -> resource , 0 , 0 , $ alpha ) ; imagefilledellipse ( $ this -> resource , $ this -> width / 2 , $ this -> height / 2 , $ this -> width , $ this -> height , $ color ) ; }
Creates a filled ellipse .
16,686
protected function fields ( SlackAttachment $ attachment ) { return collect ( $ attachment -> fields ) -> map ( function ( $ value , $ key ) { return [ 'title' => $ key , 'value' => $ value , 'short' => true ] ; } ) -> values ( ) -> all ( ) ; }
Format the attachment s fields .
16,687
protected function createNexmoDriver ( ) { return new Channels \ NexmoSmsChannel ( new NexmoClient ( new NexmoCredentials ( $ this -> app [ 'config' ] [ 'services.nexmo.key' ] , $ this -> app [ 'config' ] [ 'services.nexmo.secret' ] ) ) , $ this -> app [ 'config' ] [ 'services.nexmo.sms_from' ] ) ; }
Create an instance of the Nexmo driver .
16,688
public function getVisitorsAndPageViews ( $ numberOfDays = 365 , $ groupBy = 'date' ) { list ( $ startDate , $ endDate ) = $ this -> calculateNumberOfDays ( $ numberOfDays ) ; return $ this -> getVisitorsAndPageViewsForPeriod ( $ startDate , $ endDate , $ groupBy ) ; }
Get the amount of visitors and pageviews .
16,689
public function getVisitorsAndPageViewsForPeriod ( $ startDate , $ endDate , $ groupBy = 'date' ) { $ visitorData = [ ] ; $ answer = $ this -> performQuery ( $ startDate , $ endDate , 'ga:visits,ga:pageviews' , [ 'dimensions' => 'ga:' . $ groupBy ] ) ; foreach ( $ answer -> rows as $ dateRow ) { $ visitorData [ ] = [ $...
Get the amount of visitors and pageviews for the given period .
16,690
public function getTopKeywords ( $ numberOfDays = 365 , $ maxResults = 30 ) { list ( $ startDate , $ endDate ) = $ this -> calculateNumberOfDays ( $ numberOfDays ) ; return $ this -> getTopKeyWordsForPeriod ( $ startDate , $ endDate , $ maxResults ) ; }
Get the top keywords .
16,691
public function getTopKeyWordsForPeriod ( $ startDate , $ endDate , $ maxResults = 30 ) { $ keywordData = [ ] ; $ answer = $ this -> performQuery ( $ startDate , $ endDate , 'ga:sessions' , [ 'dimensions' => 'ga:keyword' , 'sort' => '-ga:sessions' , 'max-results' => $ maxResults , 'filters' => 'ga:keyword!=(not set);ga...
Get the top keywords for the given period .
16,692
public function getTopReferrers ( $ numberOfDays = 365 , $ maxResults = 20 ) { list ( $ startDate , $ endDate ) = $ this -> calculateNumberOfDays ( $ numberOfDays ) ; return $ this -> getTopReferrersForPeriod ( $ startDate , $ endDate , $ maxResults ) ; }
Get the top referrers .
16,693
public function getTopReferrersForPeriod ( $ startDate , $ endDate , $ maxResults ) { $ referrerData = [ ] ; $ answer = $ this -> performQuery ( $ startDate , $ endDate , 'ga:pageviews' , [ 'dimensions' => 'ga:fullReferrer' , 'sort' => '-ga:pageviews' , 'max-results' => $ maxResults ] ) ; if ( is_null ( $ answer -> row...
Get the top referrers for the given period .
16,694
public function getTopBrowsers ( $ numberOfDays = 365 , $ maxResults = 6 ) { list ( $ startDate , $ endDate ) = $ this -> calculateNumberOfDays ( $ numberOfDays ) ; return $ this -> getTopBrowsersForPeriod ( $ startDate , $ endDate , $ maxResults ) ; }
Get the top browsers .
16,695
public function getTopBrowsersForPeriod ( $ startDate , $ endDate , $ maxResults ) { $ browserData = [ ] ; $ answer = $ this -> performQuery ( $ startDate , $ endDate , 'ga:sessions' , [ 'dimensions' => 'ga:browser' , 'sort' => '-ga:sessions' ] ) ; if ( is_null ( $ answer -> rows ) ) { return new Collection ( [ ] ) ; }...
Get the top browsers for the given period .
16,696
public function getMostVisitedPages ( $ numberOfDays = 365 , $ maxResults = 20 ) { list ( $ startDate , $ endDate ) = $ this -> calculateNumberOfDays ( $ numberOfDays ) ; return $ this -> getMostVisitedPagesForPeriod ( $ startDate , $ endDate , $ maxResults ) ; }
Get the most visited pages .
16,697
public function getMostVisitedPagesForPeriod ( $ startDate , $ endDate , $ maxResults = 20 ) { $ pagesData = [ ] ; $ answer = $ this -> performQuery ( $ startDate , $ endDate , 'ga:pageviews' , [ 'dimensions' => 'ga:pagePath' , 'sort' => '-ga:pageviews' , 'max-results' => $ maxResults ] ) ; if ( is_null ( $ answer -> r...
Get the most visited pages for the given period .
16,698
public function performQuery ( $ startDate , $ endDate , $ metrics , $ others = [ ] ) { $ startDate = $ startDate -> format ( 'Y-m-d' ) ; $ endDate = $ endDate -> format ( 'Y-m-d' ) ; $ cacheName = $ this -> determineCacheName ( [ $ startDate , $ endDate , $ metrics , $ others ] ) ; if ( $ this -> useCache ( ) and Cach...
Call the query method on the autenthicated client .
16,699
private function calculateNumberOfDays ( $ numberOfDays ) { $ endDate = Carbon :: today ( ) ; $ startDate = Carbon :: today ( ) -> subDays ( $ numberOfDays ) ; return [ $ startDate , $ endDate ] ; }
Returns an array with the current date and the date minus the number of days specified .