idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
25,400
public function toXml ( ) { $ messages = '' ; foreach ( $ this -> items as $ shortMessage ) { $ messages .= $ shortMessage -> toMultipleMessagesXml ( ) ; } return $ messages ; }
Get the xml representation of the items .
25,401
public function toArray ( ) { $ messages = [ ] ; $ receivers = [ ] ; foreach ( $ this -> items as $ shortMessage ) { $ messages [ ] = $ shortMessage -> body ( ) ; $ receivers [ ] = $ shortMessage -> receiversString ( ) ; } return [ 'Msisdns' => implode ( '|' , $ receivers ) , 'Messages' => implode ( '|' , $ messages ) , ] ; }
Get the array presentation of the items .
25,402
public function indexBy ( $ callback ) { $ keys = array_map ( $ callback , $ this -> value ) ; $ value = array_combine ( $ keys , $ this -> value ) ; return $ this -> setValue ( $ value ) ; }
Maps values to keys using callback
25,403
public function mapKeys ( array $ replaces , $ strict = true ) { $ mapped = [ ] ; foreach ( $ this -> value as $ key => $ value ) { if ( isset ( $ replaces [ $ key ] ) ) { $ newKey = $ replaces [ $ key ] ; } elseif ( $ strict ) { throw new UnexpectedKeyException ( 'Key "' . $ key . '" not found in map.' ) ; } else { $ newKey = $ key ; } $ mapped [ $ newKey ] = $ value ; } $ this -> value = $ mapped ; return $ this ; }
Replaces collection keys using map array .
25,404
public function filter ( $ callback = null ) { if ( $ callback !== null ) $ value = array_filter ( $ this -> value , $ callback ) ; else $ value = array_filter ( $ this -> value ) ; return $ this -> setValue ( $ value ) ; }
Performs array_filter to each item in collection .
25,405
public function find ( $ callback ) { foreach ( $ this -> value as $ value ) { if ( call_user_func ( $ callback , $ value ) ) { return $ value ; } } return null ; }
Finds an item by callback function . Returns it s value .
25,406
public function get ( $ paramName = null , $ default = null ) { $ result = $ default ; $ params = $ this -> getRequestParams ( ) ; if ( $ paramName === null ) { $ result = $ params ; } elseif ( isset ( $ params [ $ paramName ] ) ) { $ result = $ params [ $ paramName ] ; } return $ result ; }
Get param value by name
25,407
public function getCookie ( $ name , $ default = null ) { $ result = $ default ; if ( isset ( $ _COOKIE [ $ name ] ) ) { $ result = $ _COOKIE [ $ name ] ; } return $ result ; }
Get cookie s value by name
25,408
public function getFile ( $ fileName ) { $ result = false ; if ( isset ( $ _FILES [ $ fileName ] ) ) { $ result = $ _FILES [ $ fileName ] ; } return $ result ; }
Get file by name
25,409
public function getSegment ( $ index , $ default = null ) { return $ index > 0 && count ( $ this -> urlParts ) - 1 <= $ index ? $ this -> urlParts [ $ index ] : $ default ; }
Get URL segment
25,410
protected function devideUrl ( ) { $ parts = explode ( '/' , $ this -> getPath ( ) ) ; $ cnt = count ( $ parts ) ; for ( $ i = 0 ; $ i < $ cnt ; $ i ++ ) { $ parts [ $ i ] = trim ( $ parts [ $ i ] ) ; } return $ parts ; }
Devide url on segments
25,411
public function getHeader ( $ name ) { $ name = mb_strtolower ( $ name ) ; return isset ( $ this -> headers [ $ name ] ) ? $ this -> headers [ $ name ] : null ; }
Get header by name
25,412
protected function getGeneralErrorMessage ( \ Exception $ caught ) { $ singleName = $ this -> getEntityNameSingular ( ) ; $ message = "There was an error when saving {$singleName} data: %s" ; return sprintf ( $ this -> translate ( $ message ) , $ caught -> getMessage ( ) ) ; }
Get invalid form data message
25,413
public function getUpdateService ( ) { if ( null == $ this -> updateService ) { $ this -> setUpdateService ( new EntityUpdateService ( $ this -> getNewEntity ( ) ) ) ; } return $ this -> updateService ; }
Get update service
25,414
public static function validateIP ( $ v ) { if ( $ ip = filter_var ( $ v , FILTER_VALIDATE_INT ) ) $ v = long2ip ( $ ip ) ; return filter_var ( $ v , FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 ) ; }
Validates a value as an ip4 address .
25,415
public function detailAnnouncementAction ( string $ anID ) { $ this -> checkStaticTemplateIsIncluded ( ) ; $ this -> checkSettings ( ) ; $ this -> slotExtendedAssignMultiple ( [ self :: VIEW_VARIABLE_ASSOCIATION_ID => $ this -> settings [ self :: SETTINGS_ASSOCIATION_ID ] , self :: VIEW_VARIABLE_ANNOUNCEMENT_ID => $ anID ] , __CLASS__ , __FUNCTION__ ) ; return $ this -> view -> render ( ) ; }
detail announcement action .
25,416
public function sendData ( $ userId ) { $ this -> client -> post ( 'http://api.segment.io/v1/import' , array ( 'body' => json_encode ( array ( 'secret' => $ this -> getWriteKey ( ) , 'batch' => $ this -> buildBatch ( $ userId ) ) ) ) ) ; }
Sends the data to Segment . io for the given user id .
25,417
private function buildBatch ( $ userId ) { $ batch = array ( ) ; while ( $ method = $ this -> getQueue ( ) -> dequeue ( MethodInterface :: SERVER_PLATFORM ) ) { $ batch [ ] = $ this -> getMethodData ( $ method , $ userId ) ; } return $ batch ; }
Builds the batch of method data for the given user id .
25,418
private function getMethodData ( MethodInterface $ method , $ userId ) { $ data = $ method -> getArguments ( ) ; $ data [ 'action' ] = $ method -> getName ( ) ; $ data [ 'secret' ] = $ this -> getWriteKey ( ) ; if ( ! isset ( $ data [ 'userId' ] ) && ! isset ( $ data [ 'from' ] ) ) { $ data [ 'userId' ] = $ userId ; } return $ data ; }
Get the method data for the given user id .
25,419
public function text ( $ type , $ tag ) { $ this -> deprecate ( 'text' ) ; if ( isset ( $ this -> text [ $ type ] ) ) return $ this -> text [ $ type ] -> get ( $ tag ) ; return null ; }
Return the text internal
25,420
public function getComposer ( IOInterface $ inputOutput = null ) { if ( null === $ inputOutput ) { $ inputOutput = $ this -> getInputOutput ( ) ; } RuntimeHelper :: setupHome ( $ this -> getTensideHome ( ) ) ; return ComposerFactory :: create ( $ inputOutput ) ; }
Retrieve a composer instance .
25,421
public function getNewStructure ( ) { return [ [ "type" => "singleLine" , "fieldID" => $ this -> prefix . "title" , "tabID" => trans ( "Translations" ) , "label" => trans ( "HCGalleries::galleries.title" ) , "required" => 1 , "requiredVisible" => 1 , "multiLanguage" => 1 , ] , [ "type" => "richTextArea" , "fieldID" => $ this -> prefix . "content" , "tabID" => trans ( "Translations" ) , "label" => trans ( "HCGalleries::galleries.content" ) , "multiLanguage" => 1 , ] , [ "type" => "singleLine" , "fieldID" => $ this -> prefix . "location" , "tabID" => trans ( "General" ) , "label" => trans ( "HCGalleries::galleries.location" ) , "multiLanguage" => 1 , ] , [ "type" => "dateTimePicker" , "properties" => [ "format" => "YYYY-MM-DD HH:mm:ss" , ] , "fieldID" => $ this -> prefix . "publish_at" , "tabID" => trans ( "General" ) , "label" => trans ( "HCGalleries::galleries.publish_at" ) , "requiredVisible" => 1 , ] , [ "type" => "dateTimePicker" , "properties" => [ "format" => "YYYY-MM-DD HH:mm:ss" , ] , "fieldID" => $ this -> prefix . "expires_at" , "tabID" => trans ( "General" ) , "label" => trans ( "HCGalleries::galleries.expires_at" ) , ] , [ "type" => "resource" , "fieldID" => $ this -> prefix . "images" , "tabID" => trans ( "Resources" ) , "uploadURL" => route ( "admin.api.resources" ) , "viewURL" => route ( "resource.get" , [ '/' ] ) , "sortable" => 1 , ] , ] ; }
New form structure
25,422
public function onPostPackageEvent ( PackageEvent $ event ) { $ installed_package = NULL ; $ operation = $ event -> getOperation ( ) ; if ( $ operation instanceof UpdateOperation ) { $ installed_package = $ operation -> getTargetPackage ( ) ; } else { $ installed_package = $ operation -> getPackage ( ) ; } $ package_extra = $ installed_package -> getExtra ( ) ; if ( isset ( $ package_extra ) && isset ( $ package_extra [ 'installer-paths' ] ) ) { $ composer = $ event -> getComposer ( ) ; $ composer -> getInstallationManager ( ) -> removeInstaller ( $ this -> installer ) ; $ composer -> getInstallationManager ( ) -> addInstaller ( $ this -> installer ) ; $ this -> installer -> clearCache ( ) ; } }
Event handler for to process package events .
25,423
public static function create ( $ driver , array $ args = [ ] ) { if ( is_string ( $ driver ) && lcfirst ( $ driver ) === 'doctrine' ) { return new DoctrineResourceManager ( new DoctrineDriver ( $ args ) ) ; } elseif ( $ driver instanceof DoctrineDriver ) { return new DoctrineResourceManager ( $ driver ) ; } throw new \ InvalidArgumentException ( sprintf ( 'The driver "%s" can not be found.' , is_string ( $ driver ) ? lcfirst ( $ driver ) : get_class ( $ driver ) ) ) ; }
Create a instance of ResourceManagerInterface .
25,424
public function download ( $ filename = '' ) { $ filename = $ this -> formatFilename ( $ filename ) ; if ( $ this -> content ) { $ this -> printHeader ( ) ; header ( "Content-Disposition: attachment; filename=\"" . $ filename . "\";" ) ; ob_clean ( ) ; echo $ this -> content ; } elseif ( $ this -> path ) { $ fsize = filesize ( $ this -> path ) ; $ this -> printHeader ( $ fsize ) ; header ( "Content-Disposition: attachment; filename=\"" . $ filename . "\";" ) ; ob_clean ( ) ; readfile ( $ this -> path ) ; } }
Download file in web browser .
25,425
public function indexAction ( ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entities = $ em -> getRepository ( 'VeonikBlogBundle:Tag' ) -> findAll ( ) ; return array ( 'entities' => $ entities , ) ; }
Lists all Tag entities .
25,426
public function editAction ( $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = $ em -> getRepository ( 'VeonikBlogBundle:Tag' ) -> find ( $ id ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find Tag entity.' ) ; } $ form = $ this -> createForm ( new TagType ( ) , $ entity ) ; return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; }
Displays a form to edit an existing Tag entity .
25,427
public function updateAction ( Request $ request , $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = $ em -> getRepository ( 'VeonikBlogBundle:Tag' ) -> find ( $ id ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find Tag entity.' ) ; } $ form = $ this -> createForm ( new TagType ( ) , $ entity ) ; $ form -> bind ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em -> persist ( $ entity ) ; $ em -> flush ( ) ; $ this -> getSession ( ) -> getFlashBag ( ) -> set ( 'success' , 'The tag has been updated successfully.' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'manage_tags' ) ) ; } return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; }
Edits an existing Tag entity .
25,428
public function getParameter ( \ Twig_Environment $ environment , $ parameterName , $ configAlias = null , $ debug = false ) { $ defaultConfig = $ this -> configManager -> getRepository ( ) -> getDefaultConfiguration ( ) ; $ this -> config = count ( $ defaultConfig ) > 0 ? $ defaultConfig [ 0 ] : null ; $ parameters = array ( ) ; if ( $ configAlias === null && $ this -> config !== null ) { $ params = $ this -> config -> getParameters ( ) ; } elseif ( $ this -> config !== null ) { $ config = $ this -> configManager -> getRepository ( ) -> findOneBy ( array ( 'alias' => $ configAlias ) ) ; if ( $ config === null ) { throw new \ Exception ( sprintf ( 'The configuration with name "%s" not found.' , $ configAlias ) ) ; } $ params = $ config -> getParameters ( ) ; } if ( ! isset ( $ params ) ) { return ; } foreach ( $ params as $ p ) { $ parameters [ $ p -> getName ( ) ] = $ p -> getValue ( ) ; } if ( $ debug === true && ! isset ( $ parameters [ $ parameterName ] ) ) { throw new \ Exception ( sprintf ( 'The parameter with name "%s" not found.' , $ parameterName ) ) ; } return isset ( $ parameters [ $ parameterName ] ) ? $ parameters [ $ parameterName ] : '' ; }
Return the website configuration parameter value
25,429
public function resolve ( $ path , $ baseFolder ) { if ( ! is_string ( $ path ) ) { return '' ; } if ( stripos ( $ path , 'file://' ) === 0 ) { $ path = substr ( $ path , 7 ) ; } if ( $ path === '' ) { return '' ; } if ( preg_match ( '_^\w\w+://_' , $ path ) ) { return $ this -> resolveRemotePath ( $ path ) ; } return $ this -> resolveLocalPath ( $ path , $ baseFolder ) ; }
Resolve a local or remote path .
25,430
public function renderNested ( array $ items , $ level = 0 ) { $ out = '' ; foreach ( $ items as $ item ) { $ out .= $ this -> _renderItem ( $ item , $ level ) ; } return $ out ; }
Render all nested items of a menu .
25,431
public function renderTree ( $ menuItems , $ level = null ) { $ output = '' ; $ depth = ( $ level !== null ) ? $ level : 1 ; foreach ( $ menuItems as $ key => $ menuItem ) { $ classes = [ 'menu-item' ] ; $ menuItemRow = $ this -> _View -> element ( '../Menus/__menu-item-row' , [ 'menuItem' => $ menuItem , 'level' => $ level ] ) ; if ( ! empty ( $ menuItem [ 'children' ] ) ) { $ menuItemRow .= '<ul>' . $ this -> renderTree ( $ menuItem [ 'children' ] , $ depth + 1 ) . '</ul>' ; } else { $ classes [ ] = 'no-children' ; } $ output .= '<li class="' . join ( ' ' , $ classes ) . '" data-menu-item-id="' . $ menuItem [ 'id' ] . '">' . $ menuItemRow . '</li>' ; } return $ output ; }
Used to render menu items as a ul li fake table in the backend .
25,432
protected function _buildItemClasses ( $ item ) { $ cls = [ $ this -> config ( 'itemClass' ) ] ; if ( $ this -> _isActive ( $ item ) ) { $ cls [ ] = $ this -> config ( 'itemActiveClass' ) ; } if ( $ this -> _isOpen ( $ item ) ) { $ cls [ ] = $ this -> config ( 'itemOpenClass' ) ; } return $ cls ; }
Build the css classes for a menu item .
25,433
protected function _renderLink ( $ item , $ level ) { $ templater = $ this -> templater ( ) ; if ( $ item [ 'icon' ] ?? false ) { $ attrs = [ 'class' => [ $ this -> config ( 'iconClass' ) , $ item [ 'icon' ] ] ] ; $ icon = $ this -> formatTemplate ( 'icon' , [ 'attrs' => $ templater -> formatAttributes ( $ attrs ) ] ) ; } else { $ icon = null ; } if ( $ item [ 'name_short' ] ?? false ) { $ attrs = [ 'class' => $ this -> config ( 'nameShortClass' ) ] ; $ shortName = $ this -> formatTemplate ( 'name' , [ 'attrs' => $ templater -> formatAttributes ( $ attrs ) , 'shortName' => $ item [ 'name_short' ] ] ) ; } else { $ shortName = null ; } if ( $ item [ 'name' ] ?? false ) { $ attrs = [ 'class' => $ this -> config ( 'nameClass' ) ] ; $ name = $ this -> formatTemplate ( 'name' , [ 'attrs' => $ templater -> formatAttributes ( $ attrs ) , 'name' => $ item [ 'name' ] ] ) ; } else { $ name = null ; } if ( $ this -> _hasChildren ( $ item ) ) { $ attrs = [ 'class' => $ this -> config ( 'caretClass' ) ] ; $ caret = $ this -> formatTemplate ( 'caret' , [ 'attrs' => $ templater -> formatAttributes ( $ attrs ) ] ) ; } else { $ caret = null ; } $ linkContent = $ this -> formatTemplate ( 'linkContent' , compact ( 'icon' , 'shortName' , 'name' , 'caret' ) ) ; $ options = [ 'class' => $ this -> _buildLinkClasses ( $ level ) , 'escape' => false ] ; if ( isset ( $ item [ 'url' ] ) && ! empty ( $ item [ 'url' ] ) ) { return $ this -> Guardian -> protectedLink ( $ linkContent , $ item [ 'url' ] , $ options ) ; } return $ this -> Html -> link ( $ linkContent , 'javascript:void(0)' , $ options ) ; }
Render the link of the menu item .
25,434
protected function _renderChildren ( $ item , $ level ) { if ( ! $ this -> _hasChildren ( $ item ) ) { return '' ; } $ subnavItems = $ this -> renderNested ( $ item [ 'children' ] , $ level ) ; if ( $ subnavItems === '' ) { return '' ; } $ templater = $ this -> templater ( ) ; $ htmlAttributes = [ 'class' => $ this -> _buildSubnavClasses ( $ item , $ level ) ] ; return $ this -> formatTemplate ( 'subnav' , [ 'attrs' => $ templater -> formatAttributes ( $ htmlAttributes ) , 'items' => $ subnavItems ] ) ; }
Render the subnavigation of the menu item .
25,435
protected function getPatchCollection ( ) { if ( $ this -> patchCollection === null ) { $ patchCollector = $ this -> getPatchCollector ( ) ; $ packages = $ this -> getLocalRepositoryPackages ( true ) ; $ this -> patchCollection = $ patchCollector -> collectPatches ( $ this -> composer -> getPackage ( ) , $ packages ) ; } return $ this -> patchCollection ; }
The list of patches to be applied .
25,436
protected function getPatcher ( ) { if ( $ this -> patcher === null ) { $ this -> patcher = new Patcher ( $ this -> io , $ this -> composer -> getInstallationManager ( ) , $ this -> composer -> getEventDispatcher ( ) , new ProcessExecutor ( $ this -> io ) , $ this -> getVolatileDirectory ( ) ) ; } return $ this -> patcher ; }
Get the Patcher instance .
25,437
protected function mustInstallPatchesForPackage ( PackageInterface $ package ) { $ result = false ; $ patches = $ this -> getPatchCollection ( ) -> getPatchesFor ( $ package ) ; if ( $ patches -> isEmpty ( ) ) { if ( $ this -> io -> isVerbose ( ) ) { $ this -> io -> write ( '<info>No patches found for ' . $ package -> getName ( ) . '.</info>' ) ; } } else { $ result = true ; } return $ result ; }
Should we apply patches to the package?
25,438
protected function installPatchesForPackage ( PackageInterface $ package ) { $ considerPatchErrorsAsWarnings = $ this -> considerPatchErrorsAsWarnings ( ) ; $ patches = $ this -> getPatchCollection ( ) -> getPatchesFor ( $ package ) ; $ patcher = $ this -> getPatcher ( ) ; $ appliedPatchesToSave = method_exists ( $ package , 'setExtra' ) ? array ( ) : null ; foreach ( $ patches -> getPatches ( ) as $ patch ) { try { $ patcher -> applyPatch ( $ patch , $ package ) ; if ( $ appliedPatchesToSave !== null ) { $ appliedPatchesToSave [ ] = array ( 'from-package' => $ patch -> getFromPackage ( ) -> getPrettyString ( ) , 'path' => $ patch -> getOriginalPath ( ) , 'description' => $ patch -> getDescription ( ) , ) ; } } catch ( GenericException $ x ) { $ appliedPatchesToSave = null ; if ( ! $ considerPatchErrorsAsWarnings ) { throw $ x ; } $ this -> io -> write ( '<error>' . $ x -> getMessage ( ) . '</error>' ) ; } } if ( $ appliedPatchesToSave !== null ) { $ this -> setPatchedPackageData ( $ package , array ( 'hash' => $ patches -> getHash ( ) , 'list' => $ appliedPatchesToSave , ) ) ; } }
Install the patches for a specific package .
25,439
protected function setPatchedPackageData ( PackageInterface $ package , array $ patchesAppliedData ) { $ extra = $ package -> getExtra ( ) ; $ extra [ 'patches_applied' ] = $ patchesAppliedData ; $ package -> setExtra ( $ extra ) ; $ this -> composer -> getRepositoryManager ( ) -> getLocalRepository ( ) -> write ( ) ; }
Persist the patches_applied to the package extra section .
25,440
protected function getLocalRepositoryPackages ( $ excludeRootPackage = false ) { $ repositoryManager = $ this -> composer -> getRepositoryManager ( ) ; $ localRepository = $ repositoryManager -> getLocalRepository ( ) ; $ packages = $ localRepository -> getPackages ( ) ; if ( $ excludeRootPackage ) { $ result = array ( ) ; foreach ( $ packages as $ package ) { if ( ! $ package instanceof RootPackageInterface ) { $ result [ ] = $ package ; } } } else { $ result = $ packages ; } return $ result ; }
Get the packages from the local Composer repository .
25,441
public function build ( ) { $ this -> yell ( 'Starting default build' ) ; $ this -> dirRemove ( ) ; $ this -> dirPrepare ( ) ; $ this -> phpLint ( ) ; $ this -> phpTestComplete ( ) ; $ this -> phpCodeStyle ( ) ; $ this -> apiGenerate ( ) ; $ this -> yell ( 'Build complete' ) ; }
Runs the default build process
25,442
public function integration ( ) { $ this -> yell ( 'Starting continuous integration build' ) ; $ this -> dirRemove ( ) ; $ this -> dirPrepare ( ) ; $ this -> phpLint ( ) ; $ this -> phpTestComplete ( ) ; $ this -> phpCodeStyle ( ) ; $ this -> yell ( 'Build complete' ) ; }
Runs the build process for continuous integration
25,443
public function install ( $ opts = [ 'prod' => false ] ) { $ prod = isset ( $ opts [ 'prod' ] ) && $ opts [ 'prod' ] ? true : false ; $ this -> info ( 'Installing project dependencies' ) ; $ this -> composerInstall ( [ 'prod' => $ prod ] ) ; $ this -> info ( 'Project dependencies installed' ) ; }
Installs project dependencies
25,444
public function update ( $ opts = [ 'prod' => false ] ) { $ prod = isset ( $ opts [ 'prod' ] ) && $ opts [ 'prod' ] ? true : false ; $ this -> info ( 'Updating project dependencies' ) ; $ this -> composerUpdate ( [ 'prod' => $ prod ] ) ; $ this -> info ( 'Project dependencies updated' ) ; }
Updates project dependencies
25,445
public function apiGenerate ( ) { $ paths = $ this -> getPaths ( ) ; $ this -> stopOnFail ( true ) ; $ this -> info ( 'Generating API documentation' ) ; $ this -> taskExec ( sprintf ( '%s/sami' , $ paths [ 'bin' ] ) ) -> arg ( 'update' ) -> arg ( sprintf ( '%s/sami.php' , $ paths [ 'build' ] ) ) -> printOutput ( true ) -> run ( ) ; $ this -> info ( 'API documentation generated' ) ; }
Generates API documentation
25,446
public function composerInstall ( $ opts = [ 'prod' => false ] ) { $ prod = isset ( $ opts [ 'prod' ] ) && $ opts [ 'prod' ] ? true : false ; $ paths = $ this -> getPaths ( ) ; $ this -> stopOnFail ( true ) ; $ this -> info ( 'Installing Composer dependencies' ) ; $ command = $ this -> taskExec ( 'composer' ) -> dir ( $ paths [ 'root' ] ) ; $ command -> arg ( 'install' ) -> option ( 'prefer-dist' ) ; if ( $ prod ) { $ command -> option ( 'no-dev' ) ; $ command -> option ( 'optimize-autoloader' ) ; } $ command -> printOutput ( true ) -> run ( ) ; $ this -> info ( 'Composer dependencies installed' ) ; }
Installs Composer dependencies
25,447
public function composerUpdateHash ( ) { $ paths = $ this -> getPaths ( ) ; $ this -> stopOnFail ( true ) ; $ this -> info ( 'Updating Composer lock file' ) ; $ command = $ this -> taskExec ( 'composer' ) -> dir ( $ paths [ 'root' ] ) ; $ command -> arg ( 'update' ) -> option ( 'lock' ) -> printOutput ( true ) -> run ( ) ; $ this -> info ( 'Composer lock file updated' ) ; }
Updates composer . lock file hash
25,448
public function dirPrepare ( ) { $ paths = $ this -> getPaths ( ) ; $ filesystem = $ this -> getFilesystem ( ) ; $ this -> info ( 'Preparing artifact directories' ) ; $ filesystem -> mkdir ( [ $ paths [ 'coverage' ] , $ paths [ 'reports' ] ] ) ; $ this -> info ( 'Artifact directories prepared' ) ; }
Prepares artifact directories
25,449
public function dirRemove ( ) { $ paths = $ this -> getPaths ( ) ; $ filesystem = $ this -> getFilesystem ( ) ; $ this -> info ( 'Removing artifact directories' ) ; $ filesystem -> remove ( [ $ paths [ 'coverage' ] , $ paths [ 'reports' ] ] ) ; $ this -> info ( 'Artifact directories removed' ) ; }
Removes artifact directories
25,450
public function phpCodeStyle ( $ opts = [ 'report' => false ] ) { $ report = isset ( $ opts [ 'report' ] ) && $ opts [ 'report' ] ? true : false ; $ paths = $ this -> getPaths ( ) ; $ this -> stopOnFail ( true ) ; $ this -> info ( 'Starting code style check for PHP source files' ) ; $ command = $ this -> taskExec ( 'php' ) ; $ command -> arg ( sprintf ( '%s/phpcs' , $ paths [ 'lib' ] ) ) ; if ( $ report ) { $ command -> option ( 'report=checkstyle' ) ; $ command -> option ( sprintf ( 'report-file=%s/checkstyle.xml' , $ paths [ 'reports' ] ) ) ; $ command -> option ( 'warning-severity=0' ) ; } $ command -> option ( sprintf ( 'standard=%s/phpcs.xml' , $ paths [ 'build' ] ) ) -> arg ( $ paths [ 'src' ] ) -> printOutput ( $ report ? false : true ) -> run ( ) ; $ this -> info ( 'PHP source files passed code style check' ) ; }
Performs code style check on PHP source
25,451
public function phpLint ( ) { $ paths = $ this -> getPaths ( ) ; $ this -> stopOnFail ( true ) ; $ this -> info ( 'Starting syntax check of PHP source files' ) ; $ iterator = Finder :: create ( ) -> files ( ) -> name ( '*.php' ) -> in ( $ paths [ 'src' ] ) -> sortByName ( ) ; foreach ( $ iterator as $ file ) { $ command = $ this -> taskExec ( 'php' ) ; $ command -> arg ( '-l' ) -> arg ( $ file -> getRealPath ( ) ) -> printOutput ( false ) -> run ( ) ; } $ this -> info ( 'PHP source files passed syntax check' ) ; }
Performs syntax check on PHP source
25,452
public static function BulletItem ( $ Section , $ Return = TRUE ) { $ Result = '' ; if ( self :: $ _BulletSection === FALSE ) self :: $ _BulletSection = $ Section ; elseif ( self :: $ _BulletSection != $ Section ) { $ Result = "<!-- $Section . self :: $ _BulletSep ; self :: $ _BulletSection = $ Section ; } if ( $ Return ) return $ Result ; else echo $ Result ; }
Call before writing an item and it will optionally write a bullet seperator .
25,453
public static function BulletRow ( $ Sep = FALSE ) { if ( ! $ Sep ) { if ( ! self :: $ _BulletSep ) self :: $ _BulletSep = ' ' . Bullet ( ) . ' ' ; } else { self :: $ _BulletSep = $ Sep ; } self :: $ _BulletSection = FALSE ; }
Call before starting a row of bullet - seperated items .
25,454
public static function InSection ( $ Section ) { $ Section = ( array ) $ Section ; foreach ( $ Section as $ Name ) { if ( isset ( self :: $ _Section [ $ Name ] ) ) return TRUE ; } return FALSE ; }
Returns whether or not the page is in the current section .
25,455
public static function Logo ( ) { $ Logo = C ( 'Garden.Logo' ) ; if ( $ Logo ) { $ Logo = ltrim ( $ Logo , '/' ) ; if ( StringBeginsWith ( $ Logo , 'uploads/' ) ) $ Logo = substr ( $ Logo , strlen ( 'uploads/' ) ) ; } $ Title = C ( 'Garden.Title' , 'Title' ) ; echo $ Logo ? Img ( Gdn_Upload :: Url ( $ Logo ) , array ( 'alt' => $ Title ) ) : $ Title ; }
Renders the banner logo or just the banner title if the logo is not defined .
25,456
public static function Section ( $ Section , $ Method = 'add' ) { $ Section = array_fill_keys ( ( array ) $ Section , TRUE ) ; switch ( strtolower ( $ Method ) ) { case 'add' : self :: $ _Section = array_merge ( self :: $ _Section , $ Section ) ; break ; case 'remove' : self :: $ _Section = array_diff_key ( self :: $ _Section , $ Section ) ; break ; case 'set' : self :: $ _Section = $ Section ; break ; case 'get' : default : return array_keys ( self :: $ _Section ) ; } }
The current section the site is in . This can be one or more values . Think of it like a server - side css - class .
25,457
public function escapeHtml ( $ text ) { if ( ! $ this -> escapeHtmlHelper ) { $ this -> escapeHtmlHelper = $ this -> getView ( ) -> plugin ( 'escapehtml' ) ; if ( ! $ this -> escapeHtmlHelper instanceof EscapeHtml ) { throw new Exception \ RuntimeException ( 'Helper not loaded: escapeHtml' ) ; } } return $ this -> escapeHtmlHelper -> __invoke ( $ text ) ; }
Escape html using view helper
25,458
public function escapeHtmlAttribute ( $ attribute ) { if ( ! $ this -> escapeHtmlAttrHelper ) { $ this -> escapeHtmlAttrHelper = $ this -> getView ( ) -> plugin ( 'escapehtmlattr' ) ; if ( ! $ this -> escapeHtmlAttrHelper instanceof EscapeHtmlAttr ) { throw new Exception \ RuntimeException ( 'Helper not loaded: escapeHtmlAttr' ) ; } } return $ this -> escapeHtmlAttrHelper -> __invoke ( $ attribute ) ; }
Escape html attribute using view helper
25,459
public function removeClass ( $ class ) { $ index = array_search ( ( string ) $ class , $ this -> class ) ; if ( $ index !== false ) { unset ( $ this -> class [ $ index ] ) ; } return $ this ; }
Remove a class from this element
25,460
public function setAttribute ( $ key , $ valueue ) { if ( $ key === 'class' ) { $ this -> setClass ( [ $ valueue ] ) ; } $ this -> attributes [ $ key ] = $ valueue ; return $ this ; }
Set an attribute on this element
25,461
public function setAttributes ( $ attributes ) { if ( isset ( $ attributes [ 'class' ] ) ) { $ class = $ attributes [ 'class' ] ; $ this -> setClass ( [ $ class ] ) ; unset ( $ attributes [ 'class' ] ) ; } $ this -> attributes = $ attributes ; return $ this ; }
Set attribute associative array
25,462
public function getAttributes ( ) { $ id = $ this -> getId ( ) ; $ attributes = $ this -> attributes ; $ class = implode ( ' ' , $ this -> getClass ( ) ) ; if ( $ id ) { $ attributes [ 'id' ] = $ this -> normalizeId ( $ id ) ; } if ( $ class ) { $ attributes [ 'class' ] = $ class ; } return $ attributes ; }
Get attribute associative array
25,463
protected function renderElement ( $ content = null ) { $ element = $ this -> getElement ( ) ; $ attributes = $ this -> getAttributesAsString ( ) ; $ html = '<' . $ element ; if ( $ attributes ) { $ html .= $ attributes ; } if ( is_string ( $ content ) ) { $ html .= '>' . $ content . '</' . $ element ; } $ html .= $ this -> getClosingBracket ( ) ; return $ html ; }
Render html element
25,464
protected function htmlAttribs ( $ attribs ) { $ html = '' ; $ escapeHtml = $ this -> getView ( ) -> plugin ( 'escapehtml' ) ; $ escapeHtmlAttr = $ this -> getView ( ) -> plugin ( 'escapehtmlattr' ) ; foreach ( ( array ) $ attribs as $ key => $ value ) { $ key = $ escapeHtml ( $ key ) ; $ this -> cleanHtmlAttribValue ( $ key , $ value ) ; if ( ! $ value ) { continue ; } switch ( $ key ) { case 'class' : case 'href' : $ value = $ escapeHtml ( $ value ) ; break ; default : $ value = $ escapeHtmlAttr ( $ value ) ; break ; } if ( 'id' == $ key ) { $ value = $ this -> normalizeId ( $ value ) ; } $ html .= $ this -> getKeyValuePair ( $ key , $ value ) ; } return $ html ; }
Converts an associative array to a string of tag attributes .
25,465
protected function getKeyValuePair ( $ key , $ value ) { if ( strpos ( $ value , '"' ) !== false ) { return ' ' . $ key . '=\'' . $ value . '\'' ; } return ' ' . $ key . '="' . $ value . '"' ; }
Get key value pair string
25,466
protected function getHtmlAttribValue ( $ key , $ value ) { if ( ( 'on' == substr ( $ key , 0 , 2 ) ) || ( 'constraints' == $ key ) ) { if ( ! is_scalar ( $ value ) ) { return Json :: encode ( $ value ) ; } return $ value ; } if ( is_array ( $ value ) ) { return implode ( ' ' , $ value ) ; } return $ value ; }
Get html attribute value
25,467
public function beforeCompile ( ) { $ builder = $ this -> getContainerBuilder ( ) ; $ this -> validateConfig ( $ this -> defaults ) ; $ config = $ this -> getConfig ( $ this -> defaults ) ; foreach ( $ builder -> findByType ( 'Nette\Mail\IMailer' ) as $ name => $ def ) { $ builder -> removeDefinition ( $ name ) ; } if ( $ config [ 'debugger' ] && interface_exists ( 'Tracy\IBarPanel' ) ) { $ builder -> addDefinition ( $ this -> prefix ( 'panel' ) ) -> setClass ( 'RM\MailPanel' ) -> addSetup ( '$newMessageTime' , [ $ config [ 'newMessageTime' ] ] ) -> addSetup ( '$show' , [ array_unique ( $ config [ 'show' ] ) ] ) -> addSetup ( '$autoremove' , [ $ config [ 'autoremove' ] ] ) -> addSetup ( '$hideEmpty' , [ $ config [ 'hideEmpty' ] ] ) ; } $ builder -> addDefinition ( $ this -> prefix ( 'mailer' ) ) -> setClass ( 'RM\FileMailer' , [ Helpers :: expand ( $ config [ 'tempDir' ] , $ builder -> parameters ) ] ) -> addSetup ( '@RM\MailPanel::setFileMailer' , [ '@self' ] ) -> addSetup ( '@Tracy\Bar::addPanel' , [ $ this -> prefix ( '@panel' ) ] ) ; }
Method setings extension .
25,468
public static function register ( Configurator $ config ) { $ config -> onCompile [ ] = function ( Configurator $ config , Compiler $ compiler ) { $ compiler -> addExtension ( 'mailPanel' , new MailPanelExtension ( ) ) ; } ; }
Register extension to DI Container .
25,469
public function importedAsset ( $ path , $ parameters = array ( ) ) { if ( $ this -> useController ) { $ path = $ this -> router -> generate ( "_assetic_" . $ this -> res -> getFormulaeName ( $ path ) , $ parameters ) ; } else { $ path = $ this -> assets -> getAssetUrl ( ltrim ( $ path , "/" ) ) ; } return $ path ; }
Return absolute path to imported asset
25,470
public function dispatch ( $ path = '/' , $ method = 'GET' ) { foreach ( $ this -> rules as $ rule ) { if ( $ rule -> matching ( $ path , $ method ) ) return $ rule -> toActionCaller ( $ path , $ method ) ; } throw new NotFoundException ( $ path ) ; }
dispatch to action
25,471
public function patch ( $ path , $ action = null ) { return $ this -> match ( $ path , Rule \ HttpMethodRule :: HTTP_METHOD_PATCH , $ action ) ; }
add patch routing
25,472
public function import ( $ file ) { $ rules = $ this -> yaml -> load ( $ file ) ; foreach ( $ rules as $ rule ) { list ( $ key , $ value ) = each ( $ rule ) ; switch ( $ key ) { case 'root' : $ this -> setRoot ( $ value ) ; break ; case 'match' : $ this -> addMatchRule ( $ value ) ; break ; } } }
import routing config .
25,473
public function isActionExists ( Rule \ Rule $ rule ) { return $ this -> actionChain -> existsController ( $ rule -> getController ( ) , $ rule -> getAction ( ) ) ; }
is exists targeted action ?
25,474
public function execute ( ) { $ params = $ this -> getParams ( ) ; $ url = $ this -> getUrl ( $ params ) ; return $ this -> sendRequest ( $ url , $ params ) ; }
Constructs the Request requirements and then sends the Request returning the response
25,475
protected function sendRequest ( $ url , $ params ) { $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ ch , CURLOPT_HEADER , 0 ) ; curl_setopt ( $ ch , CURLOPT_TIMEOUT , 0 ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , false ) ; if ( $ this -> isPost ( ) ) { curl_setopt ( $ ch , CURLOPT_POST , true ) ; if ( $ this -> isBinary ( ) ) { curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ this -> getBinaryArgs ( ) ) ; } else { curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ params ) ; } } else { curl_setopt ( $ ch , CURLOPT_HTTPGET , true ) ; } $ response = curl_exec ( $ ch ) ; if ( ! $ response ) { throw new Exceptions \ ViddlerException ( curl_error ( $ ch ) ) ; } else { $ response = unserialize ( $ response ) ; } curl_close ( $ ch ) ; $ response = $ this -> checkResponseForErrors ( $ response ) ; return $ response ; }
Sends the actual curl request
25,476
protected function getParams ( ) { $ params = [ "key=" . $ this -> apiKey ] ; if ( @ count ( $ this -> options [ 0 ] ) > 0 && is_array ( $ this -> options [ 0 ] ) ) { foreach ( $ this -> options [ 0 ] as $ k => $ v ) { if ( $ k != "response_type" && $ k != "apiKey" ) { array_push ( $ params , "$k=$v" ) ; } } } return $ params ; }
Builds the query object from the options property
25,477
protected function getUrl ( $ params ) { $ protocol = $ this -> getProtocol ( ) ; $ url = $ protocol . "://api.viddler.com/api/v2/" . $ this -> method . ".php" ; if ( ! $ this -> isPost ( ) && @ count ( $ params ) > 0 && is_array ( $ params ) ) { $ url .= "?" . implode ( "&" , $ params ) ; } return $ url ; }
Builds the URL for the request
25,478
protected function getBinaryArgs ( ) { $ bArgs = array ( ) ; foreach ( $ this -> options [ 0 ] as $ k => $ v ) { if ( $ k != 'file' ) { $ bArgs [ $ k ] = $ v ; } } if ( ! isset ( $ bArgs [ 'key' ] ) ) { $ bArgs [ 'key' ] = $ this -> apiKey ; } $ bArgs [ 'file' ] = curl_file_create ( $ this -> options [ 0 ] [ 'file' ] ) ; return $ bArgs ; }
Returns the binary arguments for the request
25,479
protected function checkResponseForErrors ( $ response ) { if ( isset ( $ response [ "error" ] ) ) { $ msg = [ ] ; $ parts = [ "code" , "description" , "details" ] ; foreach ( $ parts as $ part ) { if ( ! empty ( $ response [ "error" ] [ $ part ] ) ) { $ msg [ ] = $ part . ": " . $ response [ "error" ] [ $ part ] ; } } $ msg = implode ( " | " , $ msg ) ; $ code = $ response [ "error" ] [ "code" ] ; if ( ! array_key_exists ( $ code , $ this -> exceptions ) ) { $ code = "default" ; } throw new $ this -> exceptions [ $ code ] ( $ msg ) ; } return $ response ; }
Throws an Exception if the response contains an error
25,480
public function reverseTransform ( $ value ) { if ( null === $ value ) { return false ; } if ( ! is_bool ( $ value ) ) { throw new UnexpectedTypeException ( $ value , 'Boolean' ) ; } return true === $ value ? $ this -> trueValue : null ; }
Transforms a Boolean into a string .
25,481
public function getExtension ( $ reload = false ) { if ( $ reload || null === $ this -> extension ) { $ this -> extension = $ this -> loadExtension ( ) ; } return clone $ this -> extension ; }
Get the extension information .
25,482
public function getExtensionProperty ( $ property , $ default = null ) { $ extension = new Registry ( ( array ) $ this -> getExtension ( ) ) ; return $ extension -> get ( $ property , $ default ) ; }
Get an extension property .
25,483
public function get ( $ id ) { $ id = ( string ) $ id ; if ( ! $ this -> has ( $ id ) ) { throw new NotFoundException ( sprintf ( 'The item with identifier "%s" was not found.' , $ id ) ) ; } return $ this -> items [ $ id ] ; }
Returns the value of the item with given name .
25,484
public function has ( $ id ) { $ id = ( string ) $ id ; $ this -> validateName ( $ id ) ; return isset ( $ this -> items [ $ id ] ) ; }
Returns whether an item with given name is defined .
25,485
public function define ( $ id , $ type ) { $ id = ( string ) $ id ; $ this -> validateName ( $ id ) ; if ( $ type [ 0 ] == ':' ) { $ expectedType = substr ( $ type , 1 ) ; $ allowedTypes = ( array ) $ this -> getAllowedTypes ( ) ; if ( ! in_array ( $ expectedType , $ allowedTypes ) ) { throw new InvalidArgumentException ( sprintf ( 'Cannot use type %s to define item "%s" in %s container. Allowed types are: %s.' , $ expectedType , $ id , $ this -> name , join ( ', ' , $ allowedTypes ) ) ) ; } } else { if ( ! class_exists ( $ type ) ) { throw new InvalidArgumentException ( sprintf ( 'Cannot use non-existing class %s as type to define item "%s" in %s container.' , $ type , $ id , $ this -> name ) ) ; } } $ this -> typemap [ $ id ] = $ type ; }
Defines the given item in the typemap .
25,486
public function defineAll ( array $ typemap ) { foreach ( $ typemap as $ id => $ type ) { $ this -> define ( $ id , $ type ) ; } }
Defines multiple items in the typemap .
25,487
public function isDefined ( $ id ) { return isset ( $ this -> typemap [ $ id ] ) ? $ this -> typemap [ $ id ] : false ; }
Checks whether an item with given name is defined and if so which type it requires .
25,488
protected function getType ( $ value ) { if ( is_object ( $ value ) ) { return get_class ( $ value ) ; } elseif ( is_null ( $ value ) ) { return 'null' ; } elseif ( is_string ( $ value ) ) { return 'string' ; } elseif ( is_array ( $ value ) ) { return 'array' ; } elseif ( is_int ( $ value ) ) { return 'integer' ; } elseif ( is_bool ( $ value ) ) { return 'boolean' ; } elseif ( is_float ( $ value ) ) { return 'float' ; } elseif ( is_resource ( $ value ) ) { return 'resource' ; } else { return 'unknown' ; } }
Returns the type of the value .
25,489
public function postCampaignAction ( Request $ request ) { $ campaign = new Campaign ( ) ; $ campaignType = $ this -> get ( 'campaignchain.core.form.type.campaign' ) ; $ campaignType -> setView ( 'rest' ) ; $ campaignType -> setBundleName ( ScheduledCampaignController :: BUNDLE_NAME ) ; $ campaignType -> setModuleIdentifier ( ScheduledCampaignController :: MODULE_IDENTIFIER ) ; $ form = $ this -> createForm ( $ campaignType , $ campaign ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; try { $ em -> getConnection ( ) -> beginTransaction ( ) ; $ em -> persist ( $ campaign ) ; $ em -> flush ( ) ; $ hookService = $ this -> get ( 'campaignchain.core.hook' ) ; $ hookService -> processHooks ( ScheduledCampaignController :: BUNDLE_NAME , ScheduledCampaignController :: MODULE_IDENTIFIER , $ campaign , $ form , true ) ; $ campaign = $ hookService -> getEntity ( ) ; $ em -> flush ( ) ; $ em -> getConnection ( ) -> commit ( ) ; } catch ( \ Exception $ e ) { $ em -> getConnection ( ) -> rollback ( ) ; return $ this -> errorResponse ( $ e -> getMessage ( ) ) ; } return $ this -> response ( [ 'campaign' => [ 'id' => $ campaign -> getId ( ) ] ] ) ; } return $ this -> errorResponse ( $ form ) ; }
Create new Scheduled Campaign
25,490
public function enableCmdlCaching ( $ duration = null ) { if ( $ duration == null ) { $ duration = $ this -> duration ; } $ this -> cmdlCaching = $ duration ; $ checkLastModifiedDate = false ; if ( $ this -> hasLastModifiedCacheStrategy ( ) ) { $ checkLastModifiedDate = true ; } $ this -> readConnection -> enableCMDLCaching ( $ duration , $ checkLastModifiedDate ) ; if ( $ this -> writeConnection ) { $ this -> writeConnection -> enableCMDLCaching ( $ duration , $ checkLastModifiedDate ) ; } }
Allow connection to cache CMDL definitions . Adjustable via duration if you re not sure how likely CMDL changes occur .
25,491
public function accept ( VisitorInterface $ visitor ) { $ hierarchy = array_merge ( [ get_class ( $ this ) ] , array_values ( class_parents ( $ this ) ) ) ; $ visitorMethods = array_map ( function ( $ className ) { if ( strrpos ( $ className , "\\" ) !== false ) { $ className = substr ( $ className , strrpos ( $ className , "\\" ) + 1 ) ; } return "visit" . $ className ; } , $ hierarchy ) ; foreach ( $ visitorMethods as $ visitorMethod ) { if ( method_exists ( $ visitor , $ visitorMethod ) === true ) { return $ visitor -> $ visitorMethod ( $ this ) ; } } if ( method_exists ( $ visitor , "visit" ) === true ) { return $ visitor -> visit ( $ this ) ; } return null ; }
Accept a visitor per the Visitor pattern .
25,492
protected function handleProperty ( \ ReflectionProperty $ property , ClassContext $ classContext , $ original , \ stdClass $ output ) { $ propertyContext = $ this -> propertyBuilder -> propertyContextFromReflection ( $ property , $ original , $ classContext ) ; $ value = $ propertyContext -> value ; $ name = $ propertyContext -> name ; switch ( true ) : case $ this -> checkArrayCollection ( $ value ) : $ value = $ value -> toArray ( ) ; case is_array ( $ value ) ; $ output -> $ name = $ this -> handleArray ( $ value , $ classContext -> views ) ; break ; case is_object ( $ value ) ; $ output -> $ name = $ this -> handleObject ( $ value , $ classContext -> views ) ; break ; default : $ output -> $ name = $ value ; break ; endswitch ; return $ output ; }
Used to handle determining representing object properties
25,493
protected function getEmbedded ( $ representation , \ ReflectionClass $ reflection ) { $ embedded = new \ stdClass ( ) ; $ properties = $ reflection -> getProperties ( ) ; $ reader = $ this -> reader ; array_walk ( $ properties , function ( \ ReflectionProperty $ property ) use ( $ representation , $ embedded , $ reader ) { $ property -> setAccessible ( true ) ; $ annot = $ reader -> getPropertyAnnotation ( $ property , '\Represent\Annotations\Embedded' ) ; if ( $ annot ) { $ name = $ property -> getName ( ) ; $ value = $ representation -> $ name ; $ embedded -> $ name = $ value ; unset ( $ representation -> $ name ) ; } } ) ; return $ embedded ; }
Handles moving embedded properties to _embedded
25,494
protected function getLinks ( $ object , $ view ) { $ reflection = new \ ReflectionClass ( $ object ) ; $ links = new \ stdClass ( ) ; $ annot = $ this -> reader -> getClassAnnotation ( $ reflection , '\Represent\Annotations\LinkCollection' ) ; if ( $ annot ) { $ links = $ this -> parseLinks ( $ annot , $ view , $ links , $ object ) ; } return $ links ; }
Handles getting _links
25,495
protected function parseLinks ( LinkCollection $ annot , $ view , \ stdClass $ output , $ object ) { $ generator = $ this -> linkGenerator ; array_walk ( $ annot -> links , function ( $ link ) use ( $ view , $ output , $ generator , $ object ) { if ( $ view == null || in_array ( $ view , $ link -> views ) ) { $ name = $ generator -> parseName ( $ link , $ object ) ; $ output -> $ name = $ generator -> generate ( $ link , $ object ) ; } } ) ; return $ output ; }
Parses through link annotations and generates valid links
25,496
private function _prepareColumnArgument ( $ column ) { if ( ! is_string ( $ column ) && ! $ column instanceof SqlFunctionInterface ) { throw new \ InvalidArgumentException ( 'Argument 1 passed is not the expected type!' ) ; } if ( $ column instanceof SqlFunctionInterface || $ column === '*' ) { $ this -> columnName = ( string ) htmlentities ( $ column , ENT_QUOTES ) ; } else { $ this -> columnName = '`' . htmlentities ( $ column , ENT_QUOTES ) . '`' ; } }
This method validate and prepare the column name or throw an exception if an invalid argument is passed as parameter .
25,497
private function _prepareExpression ( ) { $ this -> expression = ( $ this -> tableName && $ this -> alias ) ? $ this -> tableName . '.' . $ this -> columnName . ' AS ' . $ this -> alias : ( ( $ this -> tableName && ! $ this -> alias ) ? $ this -> tableName . '.' . $ this -> columnName : ( ( ! $ this -> tableName && $ this -> alias ) ? $ this -> columnName . ' AS ' . $ this -> alias : $ this -> columnName ) ) ; }
Prepare the expression property which is at least the column name or a combination of the name alias and table reference .
25,498
public function getParentOrCreate ( $ con = null ) { if ( $ this -> isNew ( ) ) { if ( $ this -> isPrimaryKeyNull ( ) ) { $ parent = new ChildStructureNode ( ) ; $ parent -> setDescendantClass ( 'gossi\trixionary\model\Kstruktur' ) ; return $ parent ; } else { $ parent = \ gossi \ trixionary \ model \ StructureNodeQuery :: create ( ) -> findPk ( $ this -> getPrimaryKey ( ) , $ con ) ; if ( null === $ parent || null !== $ parent -> getDescendantClass ( ) ) { $ parent = new ChildStructureNode ( ) ; $ parent -> setPrimaryKey ( $ this -> getPrimaryKey ( ) ) ; $ parent -> setDescendantClass ( 'gossi\trixionary\model\Kstruktur' ) ; } return $ parent ; } } else { return ChildStructureNodeQuery :: create ( ) -> findPk ( $ this -> getPrimaryKey ( ) , $ con ) ; } }
Get or Create the parent ChildStructureNode object of the current object
25,499
public function replace ( $ oldString , $ newString ) { $ this -> stringVar = str_replace ( $ oldString , $ newString , $ this -> stringVar ) ; }
Returns a new string resulting from replacing all occurrences of oldString in this string with newString .