idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
44,500
public function getModelsPathList ( ) { if ( $ this -> _modelsPath === null ) { $ this -> _modelsPath = $ this -> getBasePath ( ) . DIRECTORY_SEPARATOR . static :: $ modelsSubdir ; $ pathList = $ this -> getBasePathList ( ) ; foreach ( $ pathList as $ path ) { $ resultPath = $ path . DIRECTORY_SEPARATOR . static :: $ modelsSubdir ; if ( is_dir ( $ resultPath ) ) { $ this -> _modelsPath = $ resultPath ; break ; } } } return $ this -> _modelsPath ; }
Will find first exists models directory from current and inheritance modules .
44,501
public function addRoutes ( ) { list ( $ rulesBefore , $ rulesAfter ) = $ this -> collectRoutes ( ) ; Yii :: $ app -> urlManager -> addRules ( $ rulesBefore , false ) ; Yii :: $ app -> urlManager -> addRules ( $ rulesAfter , true ) ; }
Add module routes defined in config .
44,502
protected function setStartLink ( $ routeConfig ) { if ( empty ( $ routeConfig [ 'startLink' ] ) && ! empty ( $ routeConfig [ 'startLinkLabel' ] ) ) { $ routeConfig [ 'startLink' ] = [ 'label' => $ routeConfig [ 'startLinkLabel' ] , 'link' => '' , ] ; } if ( ! empty ( $ routeConfig [ 'startLink' ] ) ) { if ( ! empty ( $ routeConfig [ 'startLink' ] [ 'action' ] ) ) { $ action = '/' . $ routeConfig [ 'moduleUid' ] . '/' . $ routeConfig [ 'startLink' ] [ 'action' ] ; $ route = [ $ action ] ; $ url = Url :: toRoute ( $ action ) ; } elseif ( isset ( $ routeConfig [ 'startLink' ] [ 'link' ] ) ) { $ link = $ routeConfig [ 'startLink' ] [ 'link' ] ; $ link = '/' . $ routeConfig [ 'urlPrefix' ] . ( ( $ link == '' || $ link == '?' ) ? '' : ( '/' . $ link ) ) ; $ url = Url :: toRoute ( $ link ) ; } else { throw new Exception ( "Insufficient 'link' or 'action' in 'startLink' paremeter of routeConfig" ) ; } $ tcCat = TranslationsBuilder :: getBaseTransCategory ( $ this ) ; $ label = $ routeConfig [ 'startLink' ] [ 'label' ] ; $ linkData = [ 'label' => $ label , 'tcCat' => $ tcCat , 'link' => $ url , ] ; if ( isset ( $ route ) ) $ linkData [ 'route' ] = $ route ; static :: $ _startLinks [ $ this -> uniqueId ] [ $ routeConfig [ 'routesType' ] ] = $ linkData ; } }
Set start link for module .
44,503
public static function startLink ( $ moduleUid , $ routesType ) { if ( ! empty ( static :: $ _startLinks [ $ moduleUid ] [ $ routesType ] ) ) { $ linkData = static :: $ _startLinks [ $ moduleUid ] [ $ routesType ] ; $ tcCat = $ linkData [ 'tcCat' ] ; $ tc = "{$tcCat}/module" ; if ( ! empty ( Yii :: $ app -> i18n -> translations [ "{$tcCat}*" ] ) ) { $ label = $ linkData [ 'label' ] ; $ linkData [ 'label' ] = Yii :: t ( $ tc , $ label ) ; } return $ linkData ; } return false ; }
Get start link for module .
44,504
public function transform ( $ content ) { if ( null === $ content ) { return null ; } if ( ! is_string ( $ content ) ) { throw new TransformationFailedException ( sprintf ( 'Expected string, %s given' , gettype ( $ content ) ) ) ; } $ content = StripTagsUtil :: replaceCommentWith ( $ content , StripTagsUtil :: SPAN_REPLACEMENT ) ; return $ content ; }
Transforms html comments to span elements
44,505
public function reverseTransform ( $ content ) { if ( null === $ content ) { return null ; } if ( ! is_string ( $ content ) ) { throw new TransformationFailedException ( sprintf ( 'Expected string, %s given' , gettype ( $ content ) ) ) ; } $ content = StripTagsUtil :: replaceSpanWith ( $ content , StripTagsUtil :: COMMENT_REPLACEMENT ) ; return $ content ; }
Transforms span elements to html comments
44,506
public function current ( ) { if ( $ this -> valid ( ) ) { $ key = $ this -> baseArrayMap [ $ this -> iteratorIterationPosition ] ; $ value = $ this -> baseConcreteData [ $ key ] ; return $ this -> internalFilterHooks ( $ key , $ value , 'output' ) ? $ this -> internalSanitizeHooks ( $ key , $ value , 'output' ) : null ; } }
this is necessary for Iterator Interface and return current element
44,507
public static function doInsert ( $ criteria , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( SkillGroupTableMap :: DATABASE_NAME ) ; } if ( $ criteria instanceof Criteria ) { $ criteria = clone $ criteria ; } else { $ criteria = $ criteria -> buildCriteria ( ) ; } $ query = SkillGroupQuery :: create ( ) -> mergeWith ( $ criteria ) ; return $ con -> transaction ( function ( ) use ( $ con , $ query ) { return $ query -> doInsert ( $ con ) ; } ) ; }
Performs an INSERT on the database given a SkillGroup or Criteria object .
44,508
public function render ( RendererInterface $ renderer , $ content , array $ params ) { return $ renderer -> render ( $ this -> getTemplate ( ) , $ this -> getVariables ( array_merge ( $ params , array ( 'content' => $ content , ) ) ) ) ; }
Render the widget
44,509
private function setModifiedSince ( Request $ request , Item $ item ) { if ( $ modifiedAt = $ item -> getCreation ( ) ) { $ modifiedAt -> setTimezone ( new DateTimeZone ( 'GMT' ) ) ; $ date = sprintf ( '%s GMT' , $ modifiedAt -> format ( 'l, d-M-y H:i:s' ) ) ; $ request -> addHeader ( 'If-Modified-Since' , $ date ) ; } }
Sets If - Modified - Since header if creation time is available
44,510
private function setEtag ( Request $ request , Response $ cachedResponse ) { if ( $ etag = $ cachedResponse -> getHeader ( 'ETag' ) ) { $ request -> addHeader ( 'If-None-Match' , $ etag ) ; } }
Sets ETag if available in the cached response
44,511
public function save ( $ name , $ source , $ folder , $ override = false ) { $ return = false ; try { if ( ! $ this -> storage -> exists ( $ folder ) ) { $ this -> storage -> createFolder ( $ folder ) ; } $ path = $ this -> setFilename ( $ name , $ folder , $ override ) ; $ this -> storage -> upload ( $ source , $ path , $ override ) ; $ return = array ( 'name' => $ name , 'path' => $ path , 'url' => $ this -> storage -> getUrl ( $ path ) , ) ; $ this -> error = null ; } catch ( Exception $ e ) { $ this -> error = $ e ; $ return = false ; } return $ return ; }
Salva o arquivo no storage
44,512
protected function setFilename ( & $ name , $ folder , $ override = false ) { $ folder = trim ( $ folder , '/' ) ; $ extension = strrchr ( $ name , '.' ) ; $ len = mb_strlen ( $ name ) - mb_strlen ( $ extension ) ; $ nameOrig = substr ( $ name , 0 , $ len ) ; $ num = 0 ; do { if ( ! $ override && $ num > 0 ) { $ name = "{$nameOrig}-{$num}{$extension}" ; } $ num ++ ; $ filename = "/{$folder}/{$name}" ; } while ( $ this -> storage -> exists ( $ filename ) ) ; return $ filename ; }
Crypt filename and concat with folder
44,513
public function addWord ( string $ capitalCase , string $ lowerCase = null ) { if ( $ lowerCase == null ) { $ lowerCase = strtolower ( $ capitalCase ) ; } $ index = strtolower ( $ lowerCase ) ; $ record = [ $ capitalCase , $ lowerCase ] ; $ this -> words [ $ index ] = $ record ; if ( $ index !== strtolower ( $ capitalCase ) ) { $ this -> words [ strtolower ( $ capitalCase ) ] = $ record ; } }
Add a word to the singletons dictionary .
44,514
public function getWord ( string $ word ) { if ( isset ( $ this -> words [ strtolower ( $ word ) ] ) ) { return new SpecialWord ( $ word , $ this -> words [ strtolower ( $ word ) ] [ 0 ] , $ this -> words [ strtolower ( $ word ) ] [ 1 ] ) ; } return new Word ( $ word ) ; }
Returns an instance of Word or SpecialWord for the word provided .
44,515
public function indexAction ( ) { $ this -> checkStaticTemplateIsIncluded ( ) ; $ this -> checkSettings ( ) ; $ arguments = $ this -> request -> getArguments ( ) ; return $ this -> forward ( 'listAssociations' , null , null , $ arguments ) ; }
index action .
44,516
public function listSubAssociationsAction ( string $ aID = null , string $ filter = null ) { $ this -> checkStaticTemplateIsIncluded ( ) ; $ this -> checkSettings ( ) ; $ this -> slotExtendedAssignMultiple ( [ self :: VIEW_VARIABLE_ASSOCIATION_ID => $ aID , self :: VIEW_VARIABLE_FILTER => $ this -> getAssociationsFilter ( $ filter ) , self :: VIEW_VARIABLE_USER_FILTER => $ this -> getUserAssociationsFilter ( $ filter ) ] , __CLASS__ , __FUNCTION__ ) ; return $ this -> view -> render ( ) ; }
list sub associations action .
44,517
public function detailAssociationAction ( string $ aID ) { $ this -> checkStaticTemplateIsIncluded ( ) ; $ this -> checkSettings ( ) ; $ this -> slotExtendedAssignMultiple ( [ self :: VIEW_VARIABLE_ASSOCIATION_ID => $ aID ] , __CLASS__ , __FUNCTION__ ) ; return $ this -> view -> render ( ) ; }
detail association action .
44,518
public function detailEventAction ( string $ aID , string $ eID ) { $ this -> checkStaticTemplateIsIncluded ( ) ; $ this -> checkSettings ( ) ; $ this -> slotExtendedAssignMultiple ( [ self :: VIEW_VARIABLE_ASSOCIATION_ID => $ aID , self :: VIEW_VARIABLE_EVENT_ID => $ eID ] , __CLASS__ , __FUNCTION__ ) ; return $ this -> view -> render ( ) ; }
detail event action .
44,519
public function detailFunctionaryAction ( string $ aID , string $ fID ) { $ this -> checkStaticTemplateIsIncluded ( ) ; $ this -> checkSettings ( ) ; $ this -> slotExtendedAssignMultiple ( [ self :: VIEW_VARIABLE_ASSOCIATION_ID => $ aID , self :: VIEW_VARIABLE_FUNCTIONARY_ID => $ fID ] , __CLASS__ , __FUNCTION__ ) ; return $ this -> view -> render ( ) ; }
detail functionary action .
44,520
public static function Cpv ( array $ pv , array & $ c ) { $ c [ ] = [ 0 , 0 , 0 ] ; $ c [ ] = [ 0 , 0 , 0 ] ; IAU :: Cp ( $ pv [ 0 ] , $ c [ 0 ] ) ; IAU :: Cp ( $ pv [ 1 ] , $ c [ 1 ] ) ; return ; }
- - - - - - - i a u C p v - - - - - - -
44,521
protected function exec ( $ program , $ params , $ passthru = false ) { $ this -> im_path = realpath ( $ this -> config [ 'imagemagick_dir' ] . $ program ) ; if ( ! $ this -> im_path ) { $ this -> im_path = realpath ( $ this -> config [ 'imagemagick_dir' ] . $ program . '.exe' ) ; } if ( ! $ this -> im_path ) { throw new \ RuntimeException ( "imagemagick executables not found in " . $ this -> config [ 'imagemagick_dir' ] ) ; } $ command = $ this -> im_path . " " . $ params ; $ this -> debug ( "Running command: <code>$command</code>" ) ; $ code = 0 ; $ output = null ; $ passthru ? passthru ( $ command ) : exec ( $ command , $ output , $ code ) ; if ( $ code != 0 ) { throw new \ FuelException ( "imagemagick failed to edit the image. Returned with $code.<br /><br />Command:\n <code>$command</code>" ) ; } return $ output ; }
Executes the specified imagemagick executable and returns the output .
44,522
public function setContents ( $ contents ) { $ contents_exist = file_exists ( $ contents ) ; if ( $ contents_exist ) { $ this -> contents = file_get_contents ( $ contents ) ; $ this -> updateLog ( "info" , "Page contents set from {$contents}" ) ; } else { $ this -> contents = false ; $ this -> updateLog ( "alert" , "File {$contents} not found" ) ; } return $ contents_exist ; }
Sets the Page s contents to the contents of a file
44,523
private function getTwigEnvironment ( ) { if ( null == $ this -> twigEnvironment ) { $ this -> twigEnvironment = $ this -> createTwigEnvironment ( ) ; } return $ this -> twigEnvironment ; }
Creates a twig environment if not injected
44,524
private function createTwigEnvironment ( ) { $ twigEnv = new Twig_Environment ( $ this -> getLoader ( ) , $ this -> getOptions ( ) ) ; if ( $ this -> options [ 'debug' ] ) { $ twigEnv -> addExtension ( new Twig_Extension_Debug ( ) ) ; } return $ twigEnv ; }
Creates the twig environment
44,525
private function getLoader ( ) { if ( null == $ this -> loader ) { $ this -> loader = new Twig_Loader_Filesystem ( $ this -> locations ) ; } return $ this -> loader ; }
Creates a file system loader
44,526
private function getOptions ( ) { $ options = [ ] ; foreach ( $ this -> optionsMap as $ property => $ name ) { $ options [ $ name ] = $ this -> options [ $ property ] ; } return $ options ; }
Returns current configured options
44,527
public function save ( ) { if ( $ this -> msg ) { ksort ( $ this -> msg ) ; $ file = $ this -> folder . "messages_" . $ this -> language . ".php" ; $ old = umask ( 00002 ) ; if ( file_exists ( $ file ) && ! is_writable ( $ file ) ) { throw new FileTranslatorException ( 'Cannot write to file "' . $ file . '".' ) ; } elseif ( ! file_exists ( $ file ) ) { if ( ! is_dir ( $ this -> folder ) ) { $ result = mkdir ( $ this -> folder , 0775 , true ) ; if ( ! $ result ) { throw new FileTranslatorException ( 'Cannot create directory "' . $ this -> folder . '".' ) ; } } if ( ! is_writable ( $ this -> folder ) ) { throw new FileTranslatorException ( 'Cannot write to directory "' . $ this -> folder . '".' ) ; } } $ fp = fopen ( $ file , "w" ) ; fwrite ( $ fp , "<?php\n" ) ; fwrite ( $ fp , 'return ' ) ; fwrite ( $ fp , var_export ( $ this -> msg , true ) ) ; fwrite ( $ fp , ";\n" ) ; fclose ( $ fp ) ; umask ( $ old ) ; } }
Saves the file for current language
44,528
public function deleteMessage ( $ key ) { if ( isset ( $ this -> msg [ $ key ] ) ) { unset ( $ this -> msg [ $ key ] ) ; } if ( ! $ this -> msg ) { $ this -> deleteFile ( ) ; } }
Sets the message
44,529
protected function initializeResouces ( ) { if ( $ this -> resources !== null ) { return ; } $ this -> resources = array ( ) ; $ contents = dir ( $ this -> root . $ this -> path ) ; while ( ( $ path = $ contents -> read ( ) ) !== false ) { if ( in_array ( $ path , array ( '.' , '..' , '.hg' ) ) ) { continue ; } $ this -> resources [ ] = ( is_dir ( $ this -> root . $ this -> path . $ path ) ? new \ Arbit \ VCSWrapper \ HgCli \ Directory ( $ this -> root , $ this -> path . $ path . '/' ) : new \ Arbit \ VCSWrapper \ HgCli \ File ( $ this -> root , $ this -> path . $ path ) ) ; } $ contents -> close ( ) ; }
Initialize the resources array .
44,530
public function getHandlerForCommand ( $ commandName ) { $ command = str_replace ( $ this -> commandNamespace , '' , $ commandName ) ; $ handlerName = $ this -> handlerNamespace . '\\' . trim ( $ command , '\\' ) . 'Handler' ; if ( ! class_exists ( $ handlerName ) ) { throw MissingHandlerException :: forCommand ( $ commandName ) ; } $ handler = $ this -> container -> make ( $ handlerName ) ; return $ handler ; }
Attempts to find the command s respective handler .
44,531
public function isMultiLineCall ( File $ phpcsFile , $ stackPtr , $ openBracket , $ tokens ) { $ closeBracket = $ tokens [ $ openBracket ] [ 'parenthesis_closer' ] ; if ( $ tokens [ $ openBracket ] [ 'line' ] !== $ tokens [ $ closeBracket ] [ 'line' ] ) { return true ; } return false ; }
Determine if this is a multi - line function call .
44,532
public static function addTag ( $ tag , $ class = null ) { $ tags = array ( ) ; if ( is_string ( $ tag ) ) { if ( is_null ( $ class ) ) { $ class = ucwords ( "{$tag}_Tag" ) ; } $ tags [ $ tag ] = $ class ; } elseif ( is_array ( $ tag ) ) { $ tags = $ tag ; } foreach ( $ tags as $ tag => $ tagClass ) { if ( is_integer ( $ tag ) ) { unset ( $ tags [ $ tag ] ) ; $ tag = $ tagClass ; $ tagClass = ucwords ( "{$tagClass}_Tag" ) ; } if ( ! class_exists ( $ tagClass , false ) ) { throw new H2o_Error ( "{$tagClass} tag is not found" ) ; } $ tags [ $ tag ] = $ tagClass ; } self :: $ tags = array_merge ( self :: $ tags , $ tags ) ; }
Register a new tag .
44,533
public static function addFilter ( $ filter , $ callback = null ) { if ( is_array ( $ filter ) ) { $ filters = $ filter ; foreach ( $ filters as $ key => $ filter ) { if ( is_numeric ( $ key ) ) { $ key = $ filter ; } self :: addFilter ( $ key , $ filter ) ; } return true ; } elseif ( is_string ( $ filter ) && class_exists ( $ filter , false ) && is_subclass_of ( $ filter , 'FilterCollection' ) ) { foreach ( get_class_methods ( $ filter ) as $ f ) { if ( is_callable ( array ( $ filter , $ f ) ) ) { self :: $ filters [ $ f ] = array ( $ filter , $ f ) ; } } return true ; } if ( is_null ( $ callback ) ) { $ callback = $ filter ; } if ( ! is_callable ( $ callback ) ) { return false ; } self :: $ filters [ $ filter ] = $ callback ; }
Register a new filter to h2o runtime .
44,534
protected function getArrayType ( array $ array ) { $ indices = count ( array_filter ( array_keys ( $ array ) , 'is_string' ) ) ; if ( $ indices == 0 ) { $ type = self :: ARRAY_TYPE_LIST ; } elseif ( $ indices == count ( $ array ) ) { $ type = self :: ARRAY_TYPE_DICT ; } else { $ type = self :: ARRAY_TYPE_MIXED ; } return $ type ; }
Determines wether an array is index or key based
44,535
protected function getCallbackReflection ( $ callback ) { if ( is_string ( $ callback ) && strpos ( $ callback , '::' ) !== false ) { $ callback = explode ( '::' , $ callback , 2 ) ; } switch ( true ) { case is_string ( $ callback ) && function_exists ( $ callback ) : case $ callback instanceof \ Closure : $ reflection_method = new \ ReflectionFunction ( $ callback ) ; break ; case is_object ( $ callback ) && method_exists ( $ callback , '__invoke' ) : $ callback = array ( $ callback , '__invoke' ) ; case is_array ( $ callback ) : $ reflection_method = new \ ReflectionMethod ( $ callback [ 0 ] , $ callback [ 1 ] ) ; break ; default : throw new \ LogicException ( 'Found something callable that we can\'t reflect' ) ; } return $ reflection_method ; }
Returns the reflection instance based on the type of the provided callable
44,536
protected function setCallback ( $ callback ) { if ( ! is_callable ( $ callback ) ) { throw new InvalidCallbackException ( 'Invalid callback' ) ; } $ this -> reflection_parameter = $ this -> getCallbackReflection ( $ callback ) -> getParameters ( ) ; $ this -> callback = $ callback ; return $ this ; }
Gets the reflection class for and sets the callback
44,537
protected function prepareArguments ( $ reflection_parameter , $ arguments ) { $ array_type = $ this -> getArrayType ( $ arguments ) ; $ prepared = array ( ) ; if ( $ array_type == self :: ARRAY_TYPE_LIST ) { $ prepared = $ arguments ; } elseif ( $ array_type == self :: ARRAY_TYPE_DICT ) { foreach ( $ reflection_parameter as $ parameter ) { $ name = $ parameter -> getName ( ) ; if ( isset ( $ arguments [ $ name ] ) ) { $ value = $ arguments [ $ name ] ; } else if ( $ parameter -> isDefaultValueAvailable ( ) ) { $ value = $ parameter -> getDefaultValue ( ) ; } else { throw new InvalidParameterException ( "Missing parameter '$name' on position {$parameter->getPosition()}" ) ; } $ prepared [ ] = $ value ; } } else { throw new InvalidParameterException ( 'Unable to handle mixed arrays' ) ; } return $ prepared ; }
Prepares the argument array for use with call_user_func_array
44,538
public function detailAction ( Request $ request ) { $ cart = $ this -> getCurrentCart ( ) ; $ form = $ this -> createForm ( 'EcommerceBundle\Form\CartType' , $ cart ) ; return array ( 'cart' => $ cart , 'form' => $ form -> createView ( ) ) ; }
Displays current cart summary page . The parameters includes the form .
44,539
public function addAction ( Request $ request ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ coreManager = $ this -> get ( 'core_manager' ) ; $ checkoutManager = $ this -> get ( 'checkout_manager' ) ; $ cart = $ this -> getCurrentCart ( ) ; $ emptyItem = new CartItem ( ) ; try { $ item = $ checkoutManager -> resolve ( $ emptyItem , $ request ) ; } catch ( \ Exception $ exception ) { print_r ( $ exception -> getMessage ( ) ) ; die ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'ecommerce_checkout_detail' ) ) ; } $ price = $ item -> getProduct ( ) -> getPrice ( ) ; $ item -> setUnitPrice ( $ price ) ; $ freeTransport = $ item -> getProduct ( ) -> isFreeTransport ( ) ; $ item -> setFreeTransport ( $ freeTransport ) ; $ cart -> addItem ( $ item ) ; $ cart -> calculateTotal ( ) ; $ cart -> setTotalItems ( $ cart -> countItems ( ) ) ; $ em -> persist ( $ cart ) ; $ em -> flush ( ) ; $ referer = $ coreManager -> getRefererPath ( $ request ) ; return $ this -> redirect ( $ this -> generateUrl ( 'ecommerce_checkout_detail' ) . '?referer=' . $ referer ) ; }
Adds item to cart . It uses the resolver service so you can populate the new item instance with proper values based on current request .
44,540
public function saveAction ( Request $ request ) { $ cart = $ this -> getCurrentCart ( ) ; $ form = $ this -> createForm ( CartType :: class , $ cart ) ; if ( $ form -> handleRequest ( $ request ) -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ cart ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'ecommerce_checkout_identification' ) ) ; } return array ( 'cart' => $ cart , 'form' => $ form -> createView ( ) ) ; }
This action is used to submit the cart summary form . If the form and updated cart are valid it refreshes the cart data and saves it using the operator .
44,541
public function removeAction ( $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ cart = $ this -> getCurrentCart ( ) ; $ repository = $ em -> getRepository ( 'EcommerceBundle:CartItem' ) ; $ item = $ repository -> find ( $ id ) ; if ( ! $ item || false === $ cart -> hasItem ( $ item ) ) { return $ this -> redirect ( $ this -> generateUrl ( 'ecommerce_checkout_detail' ) ) ; } $ cart -> removeItem ( $ item ) ; $ cart -> setTotalItems ( count ( $ cart -> getItems ( ) ) ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'ecommerce_checkout_detail' ) ) ; }
Removes item from cart . It takes an item id as an argument .
44,542
public function editBillingAction ( Request $ request ) { if ( $ request -> isXmlHttpRequest ( ) ) { $ em = $ this -> container -> get ( 'doctrine' ) -> getManager ( ) ; $ checkoutManager = $ this -> container -> get ( 'checkout_manager' ) ; $ address = $ checkoutManager -> getBillingAddress ( ) ; $ form = $ this -> createForm ( 'EcommerceBundle\Form\AddressType' , $ address , array ( 'token_storage' => $ this -> container -> get ( 'security.token_storage' ) ) ) ; if ( 'POST' === $ request -> getMethod ( ) ) { $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em -> persist ( $ address ) ; $ em -> flush ( ) ; $ url = $ this -> container -> get ( 'router' ) -> generate ( 'core_actor_profile' ) . '?billing=1' ; $ this -> container -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'account.address.added' ) ; return new JsonResponse ( array ( 'status' => 'success' , 'url' => $ url ) ) ; } else { $ template = $ this -> container -> get ( 'twig' ) -> render ( "EcommerceBundle:Profile:Billing/billing.form.html.twig" , array ( 'billing_form' => $ form -> createView ( ) , 'address' => $ address ) ) ; return new JsonResponse ( array ( 'status' => 'error' , 'answer' => $ template ) ) ; } } } else { throw new \ Exception ( 'Only by ajax' ) ; } }
Edit the billing address
44,543
public function setBillingAddressAction ( $ id ) { $ em = $ this -> container -> get ( 'doctrine' ) -> getManager ( ) ; $ user = $ this -> container -> get ( 'security.token_storage' ) -> getToken ( ) -> getUser ( ) ; $ address = $ em -> getRepository ( 'EcommerceBundle:Address' ) -> findOneBy ( array ( 'id' => $ id , 'actor' => $ user , ) ) ; if ( is_null ( $ address ) ) { throw new AccessDeniedException ( ) ; } $ em -> getRepository ( 'EcommerceBundle:Address' ) -> removeForBillingToAllAddresses ( $ user -> getId ( ) ) ; $ address -> setForBilling ( 1 ) ; $ em -> flush ( ) ; $ url = $ this -> container -> get ( 'router' ) -> generate ( 'core_actor_profile' ) . '?delivery=1' ; $ this -> container -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'account.address.assigned.for.billing' ) ; return new RedirectResponse ( $ url ) ; }
Set the address as the billing address
44,544
public function showDeliveryAction ( ) { $ em = $ this -> container -> get ( 'doctrine' ) -> getManager ( ) ; $ user = $ this -> container -> get ( 'security.token_storage' ) -> getToken ( ) -> getUser ( ) ; $ addresses = $ em -> getRepository ( 'EcommerceBundle:Address' ) -> findBy ( array ( 'actor' => $ user , ) ) ; return array ( 'user' => $ user , 'addresses' => $ addresses ) ; }
Show delivery addresses
44,545
public function newDeliveryAction ( Request $ request ) { if ( $ request -> isXmlHttpRequest ( ) ) { $ em = $ this -> container -> get ( 'doctrine' ) -> getManager ( ) ; $ user = $ this -> container -> get ( 'security.token_storage' ) -> getToken ( ) -> getUser ( ) ; $ country = $ em -> getRepository ( 'CoreBundle:Country' ) -> find ( 'es' ) ; $ address = new Address ( ) ; $ address -> setForBilling ( false ) ; $ address -> setCountry ( $ country ) ; $ address -> setActor ( $ user ) ; $ form = $ this -> createForm ( 'EcommerceBundle\Form\AddressType' , $ address , array ( 'token_storage' => $ this -> container -> get ( 'security.token_storage' ) ) ) ; if ( 'POST' === $ request -> getMethod ( ) ) { $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em -> persist ( $ address ) ; $ em -> flush ( ) ; $ url = $ this -> container -> get ( 'router' ) -> generate ( 'core_actor_profile' ) . '?delivery=1' ; $ this -> container -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'account.address.added' ) ; return new JsonResponse ( array ( 'status' => 'success' , 'url' => $ url ) ) ; } else { $ template = $ this -> container -> get ( 'twig' ) -> render ( "EcommerceBundle:Profile:Delivery/new.html.twig" , array ( 'delivery_form' => $ form -> createView ( ) , 'address' => $ address ) ) ; return new JsonResponse ( array ( 'status' => 'error' , 'answer' => $ template ) ) ; } } } else { throw new \ Exception ( 'Only by ajax' ) ; } }
Add delivery address
44,546
public function editDeliveryAction ( Request $ request , $ id ) { if ( $ request -> isXmlHttpRequest ( ) ) { $ em = $ this -> container -> get ( 'doctrine' ) -> getManager ( ) ; $ user = $ this -> container -> get ( 'security.token_storage' ) -> getToken ( ) -> getUser ( ) ; $ address = $ em -> getRepository ( 'EcommerceBundle:Address' ) -> findOneBy ( array ( 'id' => $ id , 'actor' => $ user , ) ) ; $ form = $ this -> createForm ( 'EcommerceBundle\Form\AddressType' , $ address , array ( 'token_storage' => $ this -> container -> get ( 'security.token_storage' ) ) ) ; if ( 'POST' === $ request -> getMethod ( ) ) { $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em -> persist ( $ address ) ; $ em -> flush ( ) ; $ url = $ this -> container -> get ( 'router' ) -> generate ( 'core_actor_profile' ) . '?delivery=1' ; $ this -> container -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'account.address.saved' ) ; return new JsonResponse ( array ( 'status' => 'success' , 'url' => $ url ) ) ; } else { $ template = $ this -> container -> get ( 'twig' ) -> render ( "EcommerceBundle:Profile:Delivery/edit.html.twig" , array ( 'delivery_form' => $ form -> createView ( ) , 'address' => $ address ) ) ; return new JsonResponse ( array ( 'status' => 'error' , 'answer' => $ template ) ) ; } } } else { throw new \ Exception ( 'Only by ajax' ) ; } }
Edit delivery addresses
44,547
public function deleteDeliveryAction ( $ id ) { $ em = $ this -> container -> get ( 'doctrine' ) -> getManager ( ) ; $ user = $ this -> container -> get ( 'security.token_storage' ) -> getToken ( ) -> getUser ( ) ; $ address = $ em -> getRepository ( 'EcommerceBundle:Address' ) -> findOneBy ( array ( 'id' => $ id , 'actor' => $ user , ) ) ; if ( is_null ( $ address ) ) { throw new AccessDeniedException ( ) ; } $ em -> remove ( $ address ) ; $ em -> flush ( ) ; $ url = $ this -> container -> get ( 'router' ) -> generate ( 'core_actor_profile' ) . '?delivery=1' ; $ this -> container -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'account.address.deleted' ) ; return new RedirectResponse ( $ url ) ; }
Delete delivery addresses
44,548
public static function Bi00 ( & $ dpsibi , & $ depsbi , & $ dra ) { $ DPBIAS = - 0.041775 * DAS2R ; $ DEBIAS = - 0.0068192 * DAS2R ; $ DRA0 = - 0.0146 * DAS2R ; $ dpsibi = $ DPBIAS ; $ depsbi = $ DEBIAS ; $ dra = $ DRA0 ; return ; }
- - - - - - - - i a u B i 0 0 - - - - - - - -
44,549
final public function offsetSet ( $ key , $ value ) { $ key = ( string ) $ key ; if ( array_key_exists ( $ key , $ this -> _stack ) ) { throw new \ DomainException ( 'Key already exists.' ) ; } $ this -> _stack [ $ key ] = $ value ; }
Sets a value to the new named location with array notation .
44,550
protected function getSiteInfo ( ) { if ( null === $ this -> siteInfo ) { $ this -> siteInfo = $ this -> getServiceLocator ( ) -> get ( 'SiteInfo' ) ; } return $ this -> siteInfo ; }
Get cached site - info
44,551
protected function getFallbackUri ( $ paragraphId , $ absolute = false ) { $ uri = '/app/' . $ this -> locale . '/paragraph/render/' . $ paragraphId ; if ( $ absolute ) { $ uri = $ this -> getSiteInfo ( ) -> getSubdomainUrl ( null , $ uri ) ; } return $ uri ; }
Get fallback uri for a paragraph
44,552
protected function getSubdomain ( $ subdomainId = null ) { static $ subdomains = array ( ) ; $ siteInfo = $ this -> getSiteInfo ( ) ; if ( empty ( $ subdomainId ) || $ siteInfo -> getSubdomainId ( ) == $ subdomainId ) { return $ siteInfo -> getSubdomain ( ) ; } if ( ! isset ( $ subdomains [ $ subdomainId ] ) ) { $ service = $ this -> getServiceLocator ( ) ; $ model = $ service -> get ( 'Grid\Core\Model\SubDomain\Model' ) ; $ subdomain = $ model -> find ( $ subdomainId ) ; if ( empty ( $ subdomain ) ) { $ subdomains [ $ subdomainId ] = '' ; } else { $ subdomains [ $ subdomainId ] = $ subdomain -> subdomain ; } } return $ subdomains [ $ subdomainId ] ; }
Get subdomain by subdomain id
44,553
protected function getUriForContent ( $ contentId , $ absolute = false ) { $ service = $ this -> getServiceLocator ( ) ; $ model = $ service -> get ( 'Grid\Core\Model\Uri\Model' ) ; $ subdomain = $ this -> getSiteInfo ( ) -> getSubdomainId ( ) ; $ uri = $ model -> findDefaultByContentLocale ( $ contentId , $ this -> locale , $ subdomain ) ; if ( empty ( $ uri ) ) { return $ this -> getFallbackUri ( $ contentId , $ absolute ) ; } $ result = '/' . $ uri -> safeUri ; if ( $ absolute || $ subdomain != $ uri -> subdomainId ) { $ result = $ this -> getSiteInfo ( ) -> getSubdomainUrl ( $ this -> getSubdomain ( $ uri -> subdomainId ) , $ result ) ; } return $ result ; }
Get uri for a content paragraph
44,554
protected function getUriById ( $ paragraphId , $ absolute = false ) { $ service = $ this -> getServiceLocator ( ) ; $ model = $ service -> get ( 'Grid\Paragraph\Model\Paragraph\Model' ) ; $ paragraph = $ model -> find ( $ paragraphId ) ; if ( empty ( $ paragraph ) ) { return '#error-paragraph-notFound:' . $ paragraphId ; } if ( 'content' == $ paragraph -> type ) { return $ this -> getUriForContent ( $ this -> contentId , $ absolute ) ; } if ( $ paragraph -> id == $ paragraph -> rootId ) { return $ this -> getFallbackUri ( $ paragraphId , $ absolute ) ; } return $ this -> getUriById ( $ paragraph -> rootId , $ absolute ) . '#paragraph-' . $ paragraph -> id ; }
Get uri by id
44,555
public function getUri ( $ absolute = false ) { if ( empty ( $ this -> contentId ) ) { return '#error-paragraph-missing:contentId' ; } if ( 'content' == $ this -> subType ) { return $ this -> getUriForContent ( $ this -> contentId , $ absolute ) ; } return $ this -> getUriById ( $ this -> contentId ) ; }
Get uri for a paragraph
44,556
public static function set_sticky ( $ key , $ value ) { if ( self :: $ sticky === null ) { self :: $ sticky = new \ Skeleton \ Core \ Web \ Session \ Sticky ( ) ; } self :: $ sticky -> $ key = $ value ; }
Set a sticky session variable
44,557
protected function registerLogs ( ) { $ this -> app -> singleton ( 'logs' , function ( $ app ) { $ config = $ this -> app -> config -> get ( 'logs' ) ; if ( $ config [ 'adapter' ] == 'loggly' ) { return new Adapters \ Loggly ( ) ; } elseif ( $ config [ 'adapter' ] == 'stackdriver' ) { return new Adapters \ Stackdriver ( ) ; } else { return new Adapters \ Monolog ( ) ; } } ) ; }
Register logs .
44,558
protected static function compile_properties ( array $ properties , $ defaults = true ) { $ p = $ properties ; $ properties = [ ] ; foreach ( $ p as $ key => $ value ) { if ( is_int ( $ key ) ) { $ key = $ value ; $ value = [ ] ; } if ( $ defaults and $ property = static :: property ( $ key , false ) ) { $ value = array_replace_recursive ( $ property , $ value ) ; } $ properties [ $ key ] = $ value ; } return $ properties ; }
Compiles skeleton properties
44,559
public static function skeleton_properties ( $ type ) { $ class = get_called_class ( ) ; if ( isset ( static :: $ _skeleton_cached [ $ class ] [ $ type ] ) ) { return static :: $ _skeleton_cached [ $ class ] [ $ type ] ; } $ var = '_' . $ type . '_properties' ; $ properties = [ ] ; if ( property_exists ( $ class , $ var ) ) { $ properties = static :: $ $ var ; } return static :: $ _skeleton_cached [ $ class ] [ $ type ] = static :: compile_properties ( $ properties ) ; }
Handles property caching
44,560
public static function fieldsets ( ) { $ class = get_called_class ( ) ; if ( array_key_exists ( $ class , static :: $ _fieldsets_cached ) ) { return static :: $ _fieldsets_cached [ $ class ] ; } $ fieldsets = [ ] ; if ( property_exists ( $ class , '_fieldsets' ) ) { $ fieldsets = [ ] ; foreach ( static :: $ _fieldsets as $ fieldset => $ config ) { if ( is_int ( $ fieldset ) ) { $ fieldset = $ config ; $ config = null ; } if ( empty ( $ config ) ) { $ config = [ 'legend' => $ fieldset , ] ; } elseif ( is_string ( $ config ) ) { $ config = [ 'legend' => $ config , ] ; } $ fieldsets [ $ fieldset ] = $ config ; } } return static :: $ _fieldsets_cached [ $ class ] = $ fieldsets ; }
Returns the model fieldsets
44,561
protected static function generateInput ( $ field , array $ propertyConfig ) { $ type = \ Arr :: get ( $ propertyConfig , 'type' , 'text' ) ; $ config = [ 'name' => $ field , 'label' => \ Arr :: get ( $ propertyConfig , 'label' , $ field ) , 'attributes' => \ Arr :: get ( $ propertyConfig , 'attributes' , [ ] ) , ] ; $ content = \ Arr :: get ( $ propertyConfig , 'options' , false ) ; if ( $ content !== false ) { foreach ( $ content as $ value => $ contentName ) { if ( is_array ( $ contentName ) ) { $ group = [ 'type' => 'optgroup' , 'label' => $ value , ] ; foreach ( $ contentName as $ optValue => $ optName ) { $ group [ 'content' ] [ ] = [ 'type' => 'option' , 'value' => $ optValue , 'content' => $ optName , ] ; } $ config [ 'content' ] [ ] = $ group ; } else { $ config [ 'content' ] [ ] = [ 'type' => 'option' , 'value' => $ value , 'content' => $ contentName , 'label' => $ contentName , ] ; } } } $ irrelevantKeys = [ 'attributes' , 'label' , 'options' , 'type' ] ; $ meta = \ Arr :: filter_keys ( $ propertyConfig , $ irrelevantKeys , true ) ; $ instance = static :: $ builder -> generateInput ( $ type , $ config ) -> setMeta ( $ meta ) ; return $ instance ; }
Processes the given field and returns an element
44,562
public static function generate_filters ( ) { if ( static :: $ builder === null ) { static :: setBuilder ( new Basic ) ; } $ form = [ ] ; foreach ( static :: list_properties ( ) as $ field => $ config ) { $ form [ ] = static :: generateInput ( $ field , $ config ) ; } return $ form ; }
Generates filters used in list
44,563
public function deserializeJSON ( $ jsonString ) { $ data = \ json_decode ( $ jsonString ) ; $ this -> clear ( ) ; foreach ( $ data as $ v ) { $ part = new EmailBodyPart ( ) ; $ part -> updateFromObject ( $ v ) ; $ this -> add ( $ v ) ; } }
Updates the element implementing this interface using a JSON representation . This means updating the state of this object with that defined in the JSON as opposed to returning a new instance of this object .
44,564
protected function findLocale ( ) { $ locale = null ; if ( PHP_SAPI == 'cli' ) { $ locale = getenv ( 'LANG' ) ; } else if ( isset ( $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ) && extension_loaded ( 'intl' ) ) { $ locale = \ Locale :: acceptFromHttp ( $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ) ; } return $ locale ; }
Find the current locale
44,565
public function handleShutdown ( ) { $ error = error_get_last ( ) ; if ( $ error !== null && $ this -> isFatal ( $ error [ 'type' ] ) ) { $ this -> handleException ( new FatalErrorException ( $ error [ 'message' ] , $ error [ 'type' ] , 0 , $ error [ 'file' ] , $ error [ 'line' ] ) ) ; } }
Convert an fatal Error to an FatalErrorException .
44,566
protected function getOptionNotation ( OptionInterface $ option ) : string { $ multiple = $ option -> isMultiple ( ) ; $ short = $ option -> getShort ( ) ; $ long = $ option -> getLong ( ) ; $ flag = $ option -> isFlag ( ) ; $ notation = '' ; if ( $ short !== null ) { $ notation .= '-' . $ short ; if ( $ flag === false ) { $ notation .= '=' ; } elseif ( $ multiple === true ) { $ notation .= '+' ; } } if ( $ long !== null ) { if ( strlen ( $ notation ) > 0 ) { $ notation .= '|' ; } $ notation .= '--' . $ long ; if ( $ flag === false ) { $ notation .= '=' ; } elseif ( $ multiple === true ) { $ notation .= '+' ; } } return $ notation ; }
Get option notation .
44,567
private function calculateSize ( ) { if ( $ this -> uri ) { clearstatcache ( true , $ this -> uri ) ; } $ stats = fstat ( $ this -> stream ) ; if ( isset ( $ stats [ static :: META_SIZE ] ) ) { $ this -> size = $ stats [ static :: META_SIZE ] ; return $ this -> size ; } return null ; }
Calculate current size of stream
44,568
protected function get_fields ( $ item , $ depth , $ args = array ( ) , $ id = 0 ) { ob_start ( ) ; do_action ( 'wp_nav_menu_item_custom_fields' , $ item -> ID , $ item , $ depth , $ args , $ id ) ; return ob_get_clean ( ) ; }
Get custom fields
44,569
public function actionInstall ( ) { $ this -> stdout ( "Run composer dump-autoload ... " ) ; $ this -> executeCommand ( '$ composer dump-autoload' ) ; $ this -> stdout ( "[DONE]\n" ) ; $ scriptComponent = $ this -> getScript ( ) ; if ( $ scripts = $ scriptComponent -> getScript ( 'yii2-yiithings-install-cmd' ) ) { if ( ! $ this -> runScripts ( $ scripts ) ) { return 1 ; } } return 0 ; }
Run installation .
44,570
public function open ( $ sessionPath , $ sessionName ) { if ( ! $ this -> opened ) { $ this -> connection = new DataBaseAR ( FALSE ) ; $ this -> connection -> connect ( $ this -> dataBase ) ; $ this -> opened = TRUE ; return TRUE ; } else { return TRUE ; } }
Abre la conexion a la base de datos si no esta abierta
44,571
public function read ( $ sessionId ) { if ( $ this -> opened ) { $ sql = $ this -> connection -> connection -> prepare ( 'SELECT session_data FROM sessions WHERE session_id = :id' ) ; $ sql -> bindValue ( 'id' , $ sessionId ) ; $ sql -> execute ( ) ; $ result = $ sql -> fetch ( \ PDO :: FETCH_ASSOC ) ; if ( $ result != NULL ) { return $ result [ 'session_data' ] ; } return '' ; } else { return '' ; } }
Lee los datos de la session de la base de datos Si no hay nada retorna
44,572
public function write ( $ sessionId , $ sessionData ) { if ( $ this -> opened ) { $ sql = $ this -> connection -> connection -> prepare ( 'REPLACE INTO sessions (session_id, session_data, session_expiration) VALUES(:id, :data, :expiration)' ) ; $ sql -> bindValue ( 'id' , $ sessionId ) ; $ sql -> bindValue ( 'data' , $ sessionData ) ; $ fecha = new \ DateTime ( ) ; $ fecha -> add ( new \ DateInterval ( $ this -> expirationTime ) ) ; $ sql -> bindValue ( 'expiration' , $ fecha -> format ( 'Y-m-d H:i:s' ) ) ; return $ sql -> execute ( ) === TRUE ; } else { return FALSE ; } }
Escribe los datos de la session en la base de datos
44,573
public function destroy ( $ sessionId ) { if ( $ this -> opened ) { $ sql = $ this -> connection -> connection -> prepare ( 'DELETE FROM sessions WHERE session_id = :id' ) ; $ sql -> bindValue ( 'id' , $ sessionId ) ; return $ sql -> execute ( ) === TRUE ; } else { return FALSE ; } }
Destruye los datos e la session de la base de datos
44,574
public function gc ( $ lifetime ) { if ( $ this -> opened ) { $ fecha = new \ DateTime ( ) ; $ sql = $ this -> connection -> connection -> prepare ( 'DELETE FROM sessions WHERE session_expiration < :fecha' ) ; $ sql -> bindValue ( 'fecha' , $ fecha -> format ( 'Y-m-d H:i:s' ) ) ; return $ sql -> execute ( ) === TRUE ; } else { return FALSE ; } }
Elimina las session en la que su tiempo de expiration sea menor que el tiempo actual
44,575
public static function init ( $ settings = null ) { if ( ! is_null ( $ settings ) ) self :: $ settings = array_replace_recursive ( self :: $ settings , $ settings ) ; }
Init the logger
44,576
public function getHtml ( string $ text ) : string { $ textAsHtml = htmlspecialchars ( $ text , ENT_QUOTES ) ; $ textWithNewLines = nl2br ( $ textAsHtml ) ; $ tokenized = $ this -> tokenizer -> tokenize ( $ textWithNewLines ) ; $ html = $ this -> bbCode -> format ( $ tokenized ) ; return $ html ; }
Transform string to html escaped string with applied bb - code .
44,577
public function doRefresh ( ) { $ this -> form -> validateElements ( ) ; if ( $ this -> form -> isValid ( ) ) { foreach ( $ this -> form -> getElements ( ) as $ element ) { $ this -> tabs -> addParams ( $ element -> getName ( ) , $ element -> getVal ( ) ) ; } } }
If form returned an action
44,578
public function getEventBus ( ) { if ( ! $ this -> eventBus ) { if ( isset ( static :: $ staticEventBus ) ) { return static :: $ staticEventBus ; } $ this -> eventBus = new Bus ; } return $ this -> eventBus ; }
Return the eventBus
44,579
protected function createDataProvider ( ) : ActiveDataProvider { $ query = $ this -> buildQuery ( ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , 'sort' => [ 'defaultOrder' => $ this -> defaultOrder ] ] ) ; if ( ! $ this -> load ( $ this -> requestData ( ) ) ) { return $ dataProvider ; } if ( ! $ this -> validate ( ) ) { $ query -> where ( '0=1' ) ; return $ dataProvider ; } $ this -> buildFilter ( $ query ) ; return $ dataProvider ; }
Create ActiveDataProvider .
44,580
protected function requestData ( ) : array { switch ( $ this -> method ) { case 'post' : return Yii :: $ app -> request -> post ( ) ; case 'get' : return Yii :: $ app -> request -> getQueryParams ( ) ; default : throw new InvalidConfigException ( 'Request method is not defined' ) ; } }
Get request data params .
44,581
protected function filterTimestamp ( & $ query , $ attr = 'updated_at' ) { if ( ! is_null ( $ this -> { $ attr } ) && strpos ( $ this -> { $ attr } , ' - ' ) !== false ) { list ( $ start_date , $ end_date ) = explode ( ' - ' , $ this -> { $ attr } ) ; $ query -> andFilterWhere ( [ '>=' , $ attr , ( int ) strtotime ( $ start_date ) ] ) ; $ query -> andFilterWhere ( [ '<=' , $ attr , ( int ) strtotime ( $ end_date ) + 24 * 3600 ] ) ; } }
Add filter on timestamp .
44,582
public function isIn ( $ directory , $ cwd = null ) { $ dir = Path :: info ( $ directory ) ; if ( $ dir -> isEmpty ( ) ) { throw new \ InvalidArgumentException ( 'Directory is empty.' ) ; } $ dir = $ dir -> normalize ( ) -> assumeDirectory ( ) ; $ self = $ this -> normalize ( ) ; if ( ! $ dir -> isAbsolute ( ) && is_null ( $ cwd ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Directory "%s" is not absolute, you have to provide a working directory.' , $ directory ) ) ; } if ( ! $ self -> isAbsolute ( ) && is_null ( $ cwd ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Path "%s" is not absolute, you have to provide a working directory.' , $ this ) ) ; } if ( ! is_null ( $ cwd ) ) { $ cwd = Path :: info ( $ cwd ) -> normalize ( ) -> assumeDirectory ( ) ; if ( ! $ cwd -> isAbsolute ( ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Working directory "%s" must be absolute.' , $ cwd ) ) ; } if ( $ cwd -> isEmpty ( ) ) { throw new \ InvalidArgumentException ( 'Working directory is empty.' ) ; } $ dir = $ dir -> abs ( $ cwd ) ; $ self = $ self -> abs ( $ cwd ) ; } if ( strpos ( $ self -> __toString ( ) , $ dir -> __toString ( ) ) === 0 ) { return true ; } return false ; }
Tests whether the path is within the given directory .
44,583
public function relativeTo ( $ directory , $ cwd = null ) { $ dir = Path :: info ( $ directory ) ; if ( $ dir -> isEmpty ( ) ) { throw new \ InvalidArgumentException ( 'Directory is empty.' ) ; } $ dir = $ dir -> normalize ( ) -> assumeDirectory ( ) ; $ self = $ this -> normalize ( ) -> dir ( ) ; if ( ! $ dir -> isAbsolute ( ) && is_null ( $ cwd ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Directory "%s" is not absolute, you have to provide a working directory.' , $ directory ) ) ; } if ( ! $ self -> isAbsolute ( ) && is_null ( $ cwd ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Path "%s" is not absolute, you have to provide a working directory.' , $ this ) ) ; } if ( ! is_null ( $ cwd ) ) { $ cwd = Path :: info ( $ cwd ) -> normalize ( ) -> assumeDirectory ( ) ; if ( ! $ cwd -> isAbsolute ( ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Working directory "%s" must be absolute.' , $ cwd ) ) ; } if ( $ cwd -> isEmpty ( ) ) { throw new \ InvalidArgumentException ( 'Working directory is empty.' ) ; } $ dir = $ dir -> abs ( $ cwd ) -> normalize ( ) ; $ self = $ self -> abs ( $ cwd ) -> normalize ( ) ; } $ i = 0 ; while ( $ i < $ dir -> partCount && $ i < $ self -> partCount && $ dir -> parts [ $ i ] === $ self -> parts [ $ i ] ) { $ i ++ ; } $ remainder = new Path ( '' ) ; $ remainder -> setParts ( array_slice ( $ self -> parts , $ i ) ) ; $ outsideDepth = $ dir -> partCount - $ i - 1 ; if ( $ outsideDepth > 0 ) { $ traversal = array_fill ( 0 , $ outsideDepth , '..' ) ; $ remainder -> setParts ( array_merge ( $ traversal , $ remainder -> parts ) ) ; } $ result = $ remainder -> resolve ( $ this -> filename ( ) ) ; return $ result -> isEmpty ( ) ? new Path ( './' ) : $ result ; }
Gets the relative path to the given directory .
44,584
public function set ( $ path ) { if ( ! is_string ( $ path ) ) { throw new \ InvalidArgumentException ( ) ; } if ( $ path === '' ) { $ this -> setParts ( [ ] ) ; } else { $ this -> setParts ( explode ( '/' , $ path ) ) ; } return $ this ; }
Set the path .
44,585
public function isEmpty ( ) { if ( $ this -> partCount === 0 ) { return true ; } if ( $ this -> partCount === 1 ) { return $ this -> firstPart === '' ; } if ( $ this -> partCount === 3 && $ this -> isStreamWrapped ( ) ) { return true ; } return false ; }
Is the this path empty?
44,586
public function isStreamWrapped ( ) { $ maybeStreamWrapped = $ this -> partCount > 1 && $ this -> firstPart !== '' && $ this -> parts [ 1 ] === '' && ':' === substr ( $ this -> firstPart , - 1 ) ; if ( ! $ maybeStreamWrapped ) { return false ; } $ name = substr ( $ this -> firstPart , 0 , - 1 ) ; return in_array ( $ name , stream_get_wrappers ( ) ) ; }
Is this a stream - wrapped path?
44,587
public function equals ( $ path ) { $ p = Path :: info ( $ path ) ; return $ p -> normalize ( ) -> get ( ) === $ this -> normalize ( ) -> get ( ) ; }
Returns true if both parts are equal after normalization .
44,588
public function dir ( ) { $ dir = clone $ this ; if ( $ this -> lastPart === '' ) { } else if ( $ this -> lastPart === '..' || $ this -> lastPart === '.' ) { $ dir -> parts [ ] = '' ; } else { array_pop ( $ dir -> parts ) ; $ dir -> parts [ ] = '' ; } $ dir -> setParts ( $ dir -> parts ) ; return $ dir ; }
Returns a new path object that points to the dirname part .
44,589
public function resolve ( $ path ) { if ( $ path instanceof Path ) { $ add = clone $ path ; } else if ( is_string ( $ path ) ) { $ add = new Path ( $ path ) ; } else { throw new \ InvalidArgumentException ( ) ; } $ base = clone $ this ; if ( $ base -> partCount === 0 ) { return $ add ; } if ( $ add -> isAbsolute ( ) ) { return $ add ; } if ( $ base -> lastPart === '' ) { array_pop ( $ base -> parts ) ; } if ( $ add -> firstPart === '' ) { array_shift ( $ add -> parts ) ; } foreach ( $ add -> parts as $ part ) { $ base -> parts [ ] = $ part ; } if ( $ add -> partCount === 0 ) { $ base -> parts [ ] = '' ; } $ base -> setParts ( $ base -> parts ) ; return $ base ; }
Adds a path to the current path and returns the new path object .
44,590
public function triggerError ( $ errorCode , $ errorMessage = '' ) { $ callError = $ errorCode ; if ( ! isset ( $ this -> error [ $ errorCode ] ) || ! is_callable ( $ this -> error [ $ errorCode ] ) ) { if ( isset ( $ this -> error [ 0 ] ) && is_callable ( $ this -> error [ 0 ] ) ) { $ callError = 0 ; } else { return ; } } $ this -> match = true ; $ this -> error [ $ callError ] ( $ errorCode , $ errorMessage ) ; exit ( $ errorCode ) ; }
Trigger an error route based on the error code and exit script with that error code
44,591
public function addJob ( $ queue , Job $ job , $ maxlen = 0 , $ async = false ) { $ command = [ 'ADDJOB' , $ queue , $ job -> getBody ( ) , $ this -> getReplicationTimeout ( ) , 'REPLICATE' , $ this -> getReplicationFactor ( ) , 'DELAY' , $ job -> getDelay ( ) , 'RETRY' , $ job -> getRetry ( ) , 'TTL' , $ job -> getTtL ( ) , ] ; if ( $ maxlen ) { $ command [ ] = 'MAXLEN' ; $ command [ ] = ( int ) $ maxlen ; } if ( $ async ) { $ command [ ] = 'ASYNC' ; } $ id = $ this -> send ( $ command ) ; $ job -> setId ( $ id ) ; $ job -> setQueue ( $ queue ) ; return $ job ; }
Enqueue the given job .
44,592
public function show ( $ id ) { $ file = $ this -> repository -> getById ( $ id ) ; if ( ! $ file ) { return $ this -> errorNotFound ( ) ; } $ this -> authorize ( 'read' , $ file ) ; return new FileResource ( $ file ) ; }
Display a specified file .
44,593
public function setHeading ( $ column ) { $ columns = is_array ( $ column ) ? $ column : func_get_args ( ) ; $ this -> _head = array_values ( $ columns ) ; return $ this ; }
Set the columns for the table heading .
44,594
public function setRow ( $ column ) { $ columns = is_array ( $ column ) ? $ column : func_get_args ( ) ; if ( array_keys ( $ columns ) === range ( 0 , count ( $ columns ) - 1 ) ) { $ assocArray = array ( ) ; for ( $ i = 0 ; $ i < count ( $ this -> _head ) ; $ i ++ ) { $ assocArray [ $ this -> _head [ $ i ] ] = isset ( $ columns [ $ i ] ) ? $ columns [ $ i ] : '' ; } $ columns = $ assocArray ; } $ this -> _rows [ ] = $ columns ; return $ this ; }
Sets the colums for a table row .
44,595
public function setRows ( array $ rows ) { if ( isset ( $ rows [ '_head' ] ) ) { $ this -> setHeading ( $ rows [ '_head' ] ) ; unset ( $ rows [ '_head' ] ) ; } if ( ! empty ( $ rows ) ) { foreach ( $ rows as $ row ) { $ this -> setRow ( $ row ) ; } } return $ this ; }
Set several rows at once . You can also set the heading by providing an array item with the key of _head .
44,596
public function render ( ) { $ output = "<table {$this->renderAttributes()} >\n\t<tbody>\n" ; $ output .= "\t\t<th>\n" ; foreach ( $ this -> _head as $ heading ) { $ output .= "\t\t\t<td>{$heading}</td>\n" ; } $ output .= "\t\t</th>\n" ; foreach ( $ this -> _rows as $ row ) { $ output .= "\t\t<tr>\n" ; foreach ( $ this -> _head as $ columnName ) { $ column = $ row [ $ columnName ] ; switch ( gettype ( $ column ) ) { case 'array' : $ column = print_r ( $ column , true ) ; break ; case 'object' : $ column = ( method_exists ( $ column , 'render' ) ) ? $ column -> render ( ) : 'Object' ; break ; case 'boolean' : $ column = $ column ? 'True' : 'False' ; break ; case 'unknown type' : case 'resource' : case 'NULL' : $ column = 'NULL' ; default : break ; } $ output .= "\t\t\t<td>{$column}</td>\n" ; } $ output .= "\t\t</tr>\n" ; } $ output .= "\t</tbody>\n</table>" ; return $ output ; }
Renders the table and returns it as a string .
44,597
protected function getElementType ( ) { $ class = $ this -> getElementClass ( $ this ) ; $ parts = explode ( '\\' , $ class ) ; $ type = end ( $ parts ) ; $ replace = '$1_$2' ; return ctype_lower ( $ type ) ? $ type : strtolower ( preg_replace ( '/(.)([A-Z])/' , $ replace , $ type ) ) ; }
Returns friendly element type used for example in Twig macros
44,598
protected function getJavascriptNodeName ( ElementInterface $ element ) { $ class = $ this -> getElementClass ( $ element ) ; $ parts = explode ( '\\' , $ class ) ; return 'GForm' . end ( $ parts ) ; }
Returns element javascript - friendly name
44,599
public static function define ( $ section , \ Closure $ closure ) { $ config = call_user_func ( $ closure , self :: getInstance ( ) ) ; if ( ! is_array ( $ config ) ) { throw new \ Exception ( "You should return an array in the Configuration::define closure!" ) ; } self :: getInstance ( ) -> add ( $ section , $ config ) ; }
Define multiple configuration keys and values in a closure .