code
stringlengths
17
247k
docstring
stringlengths
30
30.3k
func_name
stringlengths
1
89
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
153
url
stringlengths
51
209
license
stringclasses
4 values
protected function _resize($element = 'this', $js = '') { return $this->_add_event($element, $js, 'resize'); }
Resize Outputs a jQuery resize event @param string The element to attach the event to @param string The code to execute @return string
_resize
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _scroll($element = 'this', $js = '') { return $this->_add_event($element, $js, 'scroll'); }
Scroll Outputs a jQuery scroll event @param string The element to attach the event to @param string The code to execute @return string
_scroll
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _unload($element = 'this', $js = '') { return $this->_add_event($element, $js, 'unload'); }
Unload Outputs a jQuery unload event @param string The element to attach the event to @param string The code to execute @return string
_unload
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _addClass($element = 'this', $class = '') { $element = $this->_prep_element($element); return '$('.$element.').addClass("'.$class.'");'; }
Add Class Outputs a jQuery addClass event @param string $element @param string $class @return string
_addClass
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _fadeIn($element = 'this', $speed = '', $callback = '') { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); if ($callback !== '') { $callback = ", function(){\n{$callback}\n}"; } return "$({$element}).fadeIn({$speed}{$callback});"; }
Fade In Outputs a jQuery hide event @param string - element @param string - One of 'slow', 'normal', 'fast', or time in milliseconds @param string - Javascript callback function @return string
_fadeIn
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _fadeOut($element = 'this', $speed = '', $callback = '') { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); if ($callback !== '') { $callback = ", function(){\n{$callback}\n}"; } return '$('.$element.').fadeOut('.$speed.$callback.');'; }
Fade Out Outputs a jQuery hide event @param string - element @param string - One of 'slow', 'normal', 'fast', or time in milliseconds @param string - Javascript callback function @return string
_fadeOut
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _hide($element = 'this', $speed = '', $callback = '') { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); if ($callback !== '') { $callback = ", function(){\n{$callback}\n}"; } return "$({$element}).hide({$speed}{$callback});"; }
Hide Outputs a jQuery hide action @param string - element @param string - One of 'slow', 'normal', 'fast', or time in milliseconds @param string - Javascript callback function @return string
_hide
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _removeClass($element = 'this', $class = '') { $element = $this->_prep_element($element); return '$('.$element.').removeClass("'.$class.'");'; }
Remove Class Outputs a jQuery remove class event @param string $element @param string $class @return string
_removeClass
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _slideUp($element = 'this', $speed = '', $callback = '') { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); if ($callback !== '') { $callback = ", function(){\n{$callback}\n}"; } return '$('.$element.').slideUp('.$speed.$callback.');'; }
Slide Up Outputs a jQuery slideUp event @param string - element @param string - One of 'slow', 'normal', 'fast', or time in milliseconds @param string - Javascript callback function @return string
_slideUp
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _slideDown($element = 'this', $speed = '', $callback = '') { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); if ($callback !== '') { $callback = ", function(){\n{$callback}\n}"; } return '$('.$element.').slideDown('.$speed.$callback.');'; }
Slide Down Outputs a jQuery slideDown event @param string - element @param string - One of 'slow', 'normal', 'fast', or time in milliseconds @param string - Javascript callback function @return string
_slideDown
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _slideToggle($element = 'this', $speed = '', $callback = '') { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); if ($callback !== '') { $callback = ", function(){\n{$callback}\n}"; } return '$('.$element.').slideToggle('.$speed.$callback.');'; }
Slide Toggle Outputs a jQuery slideToggle event @param string - element @param string - One of 'slow', 'normal', 'fast', or time in milliseconds @param string - Javascript callback function @return string
_slideToggle
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _toggle($element = 'this') { $element = $this->_prep_element($element); return '$('.$element.').toggle();'; }
Toggle Outputs a jQuery toggle event @param string - element @return string
_toggle
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _toggleClass($element = 'this', $class = '') { $element = $this->_prep_element($element); return '$('.$element.').toggleClass("'.$class.'");'; }
Toggle Class Outputs a jQuery toggle class event @param string $element @param string $class @return string
_toggleClass
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _show($element = 'this', $speed = '', $callback = '') { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); if ($callback !== '') { $callback = ", function(){\n{$callback}\n}"; } return '$('.$element.').show('.$speed.$callback.');'; }
Show Outputs a jQuery show event @param string - element @param string - One of 'slow', 'normal', 'fast', or time in milliseconds @param string - Javascript callback function @return string
_show
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _updater($container = 'this', $controller = '', $options = '') { $container = $this->_prep_element($container); $controller = (strpos('://', $controller) === FALSE) ? $controller : $this->CI->config->site_url($controller); // ajaxStart and ajaxStop are better choices here... but this is a stop gap if ($this->CI->config->item('javascript_ajax_img') === '') { $loading_notifier = 'Loading...'; } else { $loading_notifier = '<img src="'.$this->CI->config->slash_item('base_url').$this->CI->config->item('javascript_ajax_img').'" alt="Loading" />'; } $updater = '$('.$container.").empty();\n" // anything that was in... get it out ."\t\t$(".$container.').prepend("'.$loading_notifier."\");\n"; // to replace with an image $request_options = ''; if ($options !== '') { $request_options .= ', {' .(is_array($options) ? "'".implode("', '", $options)."'" : "'".str_replace(':', "':'", $options)."'") .'}'; }
Updater An Ajax call that populates the designated DOM node with returned content @param string The element to attach the event to @param string the controller to run the call against @param string optional parameters @return string
_updater
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
public function modal($src, $relative = FALSE) { $this->jquery_code_for_load[] = $this->external($src, $relative); }
Modal window Load a thickbox modal window @param string $src @param bool $relative @return void
modal
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
public function ui($src, $relative = FALSE) { $this->jquery_code_for_load[] = $this->external($src, $relative); }
UI Load a user interface library @param string $src @param bool $relative @return void
ui
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _add_event($element, $js, $event) { if (is_array($js)) { $js = implode("\n\t\t", $js); } $event = "\n\t$(".$this->_prep_element($element).').'.$event."(function(){\n\t\t{$js}\n\t});\n"; $this->jquery_code_for_compile[] = $event; return $event; }
Add Event Constructs the syntax for an event, and adds to into the array for compilation @param string The element to attach the event to @param string The code to execute @param string The event to pass @return string
_add_event
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _compile($view_var = 'script_foot', $script_tags = TRUE) { // External references $external_scripts = implode('', $this->jquery_code_for_load); $this->CI->load->vars(array('library_src' => $external_scripts)); if (count($this->jquery_code_for_compile) === 0) { // no inline references, let's just return return; } // Inline references $script = '$(document).ready(function() {'."\n" .implode('', $this->jquery_code_for_compile) .'});'; $output = ($script_tags === FALSE) ? $script : $this->inline($script); $this->CI->load->vars(array($view_var => $output)); }
Compile As events are specified, they are stored in an array This function compiles them all for output on a page @param string $view_var @param bool $script_tags @return void
_compile
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _clear_compile() { $this->jquery_code_for_compile = array(); }
Clear Compile Clears the array of script events collected for output @return void
_clear_compile
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _document_ready($js) { is_array($js) OR $js = array($js); foreach ($js as $script) { $this->jquery_code_for_compile[] = $script; } }
Document Ready A wrapper for writing document.ready() @param array $js @return void
_document_ready
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
public function script($library_src = '', $relative = FALSE) { $library_src = $this->external($library_src, $relative); $this->jquery_code_for_load[] = $library_src; return $library_src; }
Script Tag Outputs the script tag that loads the jquery.js file into an HTML document @param string $library_src @param bool $relative @return string
script
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _prep_element($element) { if ($element !== 'this') { $element = '"'.$element.'"'; } return $element; }
Prep Element Puts HTML element in quotes for use in jQuery code unless the supplied element is the Javascript 'this' object, in which case no quotes are added @param string @return string
_prep_element
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
protected function _validate_speed($speed) { if (in_array($speed, array('slow', 'normal', 'fast'))) { return '"'.$speed.'"'; } elseif (preg_match('/[^0-9]/', $speed)) { return ''; } return $speed; }
Validate Speed Ensures the speed parameter is valid for jQuery @param string @return string
_validate_speed
php
ronknight/InventorySystem
system/libraries/Javascript/Jquery.php
https://github.com/ronknight/InventorySystem/blob/master/system/libraries/Javascript/Jquery.php
MIT
public function getIncludes() { return isset($this->json['extra']['merge-plugin']['include']) ? $this->fixRelativePaths($this->json['extra']['merge-plugin']['include']) : []; }
Get list of additional packages to include if precessing recursively. @return array
getIncludes
php
wikimedia/composer-merge-plugin
src/ExtraPackage.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/ExtraPackage.php
MIT
public function getRequires() { return isset($this->json['extra']['merge-plugin']['require']) ? $this->fixRelativePaths($this->json['extra']['merge-plugin']['require']) : []; }
Get list of additional packages to require if precessing recursively. @return array
getRequires
php
wikimedia/composer-merge-plugin
src/ExtraPackage.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/ExtraPackage.php
MIT
public function getMergedRequirements() { return array_keys($this->mergedRequirements); }
Get list of merged requirements from this package. @return string[]
getMergedRequirements
php
wikimedia/composer-merge-plugin
src/ExtraPackage.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/ExtraPackage.php
MIT
protected function readPackageJson($path) { $file = new JsonFile($path); $json = $file->read(); if (!isset($json['name'])) { $json['name'] = 'merge-plugin/' . strtr($path, DIRECTORY_SEPARATOR, '-'); } if (!isset($json['version'])) { $json['version'] = '1.0.0'; } return $json; }
Read the contents of a composer.json style file into an array. The package contents are fixed up to be usable to create a Package object by providing dummy "name" and "version" values if they have not been provided in the file. This is consistent with the default root package loading behavior of Composer. @param string $path @return array
readPackageJson
php
wikimedia/composer-merge-plugin
src/ExtraPackage.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/ExtraPackage.php
MIT
public function mergeInto(RootPackageInterface $root, PluginState $state) { $this->prependRepositories($root); $this->mergeRequires('require', $root, $state); $this->mergePackageLinks('conflict', $root); if ($state->shouldMergeReplace()) { $this->mergePackageLinks('replace', $root); } $this->mergePackageLinks('provide', $root); $this->mergeSuggests($root); $this->mergeAutoload('autoload', $root); $this->mergeExtra($root, $state); $this->mergeScripts($root, $state); if ($state->isDevMode()) { $this->mergeDevInto($root, $state); } else { $this->mergeReferences($root); $this->mergeAliases($root); } }
Merge this package into a RootPackageInterface @param RootPackageInterface $root @param PluginState $state
mergeInto
php
wikimedia/composer-merge-plugin
src/ExtraPackage.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/ExtraPackage.php
MIT
public function mergeDevInto(RootPackageInterface $root, PluginState $state) { $this->mergeRequires('require-dev', $root, $state); $this->mergeAutoload('devAutoload', $root); $this->mergeReferences($root); $this->mergeAliases($root); }
Merge just the dev portion into a RootPackageInterface @param RootPackageInterface $root @param PluginState $state
mergeDevInto
php
wikimedia/composer-merge-plugin
src/ExtraPackage.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/ExtraPackage.php
MIT
protected function mergeRequires( $type, RootPackageInterface $root, PluginState $state ) { $linkType = BasePackage::$supportedLinkTypes[$type]; $getter = 'get' . ucfirst($linkType['method']); $setter = 'set' . ucfirst($linkType['method']); $requires = $this->package->{$getter}(); if (empty($requires)) { return; } $this->mergeStabilityFlags($root, $requires); $requires = $this->replaceSelfVersionDependencies( $type, $requires, $root ); $root->{$setter}($this->mergeOrDefer( $type, $root->{$getter}(), $requires, $state )); }
Merge require or require-dev into a RootPackageInterface @param string $type 'require' or 'require-dev' @param RootPackageInterface $root @param PluginState $state
mergeRequires
php
wikimedia/composer-merge-plugin
src/ExtraPackage.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/ExtraPackage.php
MIT
protected function mergeOrDefer( $type, array $origin, array $merge, PluginState $state ) { if ($state->ignoreDuplicateLinks() && $state->replaceDuplicateLinks()) { $this->logger->warning("Both replace and ignore-duplicates are true. These are mutually exclusive."); $this->logger->warning("Duplicate packages will be ignored."); } foreach ($merge as $name => $link) { if (isset($origin[$name])) { if ($state->ignoreDuplicateLinks()) { $this->logger->info("Ignoring duplicate <comment>{$name}</comment>"); continue; } if ($state->replaceDuplicateLinks()) { $this->logger->info("Replacing <comment>{$name}</comment>"); $this->mergedRequirements[$name] = true; $origin[$name] = $link; } else { $this->logger->info("Merging <comment>{$name}</comment>"); $this->mergedRequirements[$name] = true; $origin[$name] = $this->mergeConstraints($origin[$name], $link, $state); } } else { $this->logger->info("Adding <comment>{$name}</comment>"); $this->mergedRequirements[$name] = true; $origin[$name] = $link; } } if (!$state->isComposer1()) { Intervals::clear(); } return $origin; }
Merge two collections of package links and collect duplicates for subsequent processing. @param string $type 'require' or 'require-dev' @param array $origin Primary collection @param array $merge Additional collection @param PluginState $state @return array Merged collection
mergeOrDefer
php
wikimedia/composer-merge-plugin
src/ExtraPackage.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/ExtraPackage.php
MIT
protected function mergeConstraints(Link $origin, Link $merge, PluginState $state) { $oldPrettyString = $origin->getConstraint()->getPrettyString(); $newPrettyString = $merge->getConstraint()->getPrettyString(); if ($state->isComposer1()) { $constraintClass = MultiConstraint::class; } else { $constraintClass = \Composer\Semver\Constraint\MultiConstraint::class; if (Intervals::isSubsetOf($origin->getConstraint(), $merge->getConstraint())) { return $origin; } if (Intervals::isSubsetOf($merge->getConstraint(), $origin->getConstraint())) { return $merge; } } $newConstraint = $constraintClass::create([ $origin->getConstraint(), $merge->getConstraint() ], true); $newConstraint->setPrettyString($oldPrettyString.', '.$newPrettyString); return new Link( $origin->getSource(), $origin->getTarget(), $newConstraint, $origin->getDescription(), $origin->getPrettyConstraint() . ', ' . $newPrettyString ); }
Merge package constraints. Adapted from Composer's UpdateCommand::appendConstraintToLink @param Link $origin The base package link. @param Link $merge The related package link to merge. @param PluginState $state @return Link Merged link.
mergeConstraints
php
wikimedia/composer-merge-plugin
src/ExtraPackage.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/ExtraPackage.php
MIT
protected function mergeAutoload($type, RootPackageInterface $root) { $getter = 'get' . ucfirst($type); $setter = 'set' . ucfirst($type); $autoload = $this->package->{$getter}(); if (empty($autoload)) { return; } $unwrapped = self::unwrapIfNeeded($root, $setter); $unwrapped->{$setter}(array_merge_recursive( $root->{$getter}(), $this->fixRelativePaths($autoload) )); }
Merge autoload or autoload-dev into a RootPackageInterface @param string $type 'autoload' or 'devAutoload' @param RootPackageInterface $root
mergeAutoload
php
wikimedia/composer-merge-plugin
src/ExtraPackage.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/ExtraPackage.php
MIT
protected function mergeStabilityFlags( RootPackageInterface $root, array $requires ) { $flags = $root->getStabilityFlags(); $sf = new StabilityFlags($flags, $root->getMinimumStability()); $unwrapped = self::unwrapIfNeeded($root, 'setStabilityFlags'); $unwrapped->setStabilityFlags(array_merge( $flags, $sf->extractAll($requires) )); }
Extract and merge stability flags from the given collection of requires and merge them into a RootPackageInterface @param RootPackageInterface $root @param array $requires
mergeStabilityFlags
php
wikimedia/composer-merge-plugin
src/ExtraPackage.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/ExtraPackage.php
MIT
protected function mergePackageLinks($type, RootPackageInterface $root) { $linkType = BasePackage::$supportedLinkTypes[$type]; $getter = 'get' . ucfirst($linkType['method']); $setter = 'set' . ucfirst($linkType['method']); $links = $this->package->{$getter}(); if (!empty($links)) { $unwrapped = self::unwrapIfNeeded($root, $setter); // @codeCoverageIgnoreStart if ($root !== $unwrapped) { $this->logger->warning( 'This Composer version does not support ' . "'{$type}' merging for aliased packages." ); } // @codeCoverageIgnoreEnd $unwrapped->{$setter}(array_merge( $root->{$getter}(), $this->replaceSelfVersionDependencies($type, $links, $root) )); } }
Merge package links of the given type into a RootPackageInterface @param string $type 'conflict', 'replace' or 'provide' @param RootPackageInterface $root
mergePackageLinks
php
wikimedia/composer-merge-plugin
src/ExtraPackage.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/ExtraPackage.php
MIT
protected function mergeSuggests(RootPackageInterface $root) { $suggests = $this->package->getSuggests(); if (!empty($suggests)) { $unwrapped = self::unwrapIfNeeded($root, 'setSuggests'); $unwrapped->setSuggests(array_merge( $root->getSuggests(), $suggests )); } }
Merge suggested packages into a RootPackageInterface @param RootPackageInterface $root
mergeSuggests
php
wikimedia/composer-merge-plugin
src/ExtraPackage.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/ExtraPackage.php
MIT
public function mergeScripts(RootPackageInterface $root, PluginState $state) { $scripts = $this->package->getScripts(); if (!$state->shouldMergeScripts() || empty($scripts)) { return; } $rootScripts = $root->getScripts(); $unwrapped = self::unwrapIfNeeded($root, 'setScripts'); if ($state->replaceDuplicateLinks()) { $unwrapped->setScripts( array_merge($rootScripts, $scripts) ); } else { $unwrapped->setScripts( array_merge($scripts, $rootScripts) ); } }
Merge scripts config into a RootPackageInterface @param RootPackageInterface $root @param PluginState $state
mergeScripts
php
wikimedia/composer-merge-plugin
src/ExtraPackage.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/ExtraPackage.php
MIT
public static function mergeExtraArray($mergeDeep, $array1, $array2) { if ($mergeDeep) { return NestedArray::mergeDeep($array1, $array2); } return array_merge($array1, $array2); }
Merges two arrays either via arrayMergeDeep or via array_merge. @param bool $mergeDeep @param array $array1 @param array $array2 @return array
mergeExtraArray
php
wikimedia/composer-merge-plugin
src/ExtraPackage.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/ExtraPackage.php
MIT
public static function unwrapIfNeeded( RootPackageInterface $root, $method = 'setExtra' ) { // @codeCoverageIgnoreStart if ($root instanceof RootAliasPackage && !method_exists($root, $method) ) { // Unwrap and return the aliased RootPackage. $root = $root->getAliasOf(); } // @codeCoverageIgnoreEnd return $root; }
Get a full featured Package from a RootPackageInterface. In Composer versions before 599ad77 the RootPackageInterface only defines a sub-set of operations needed by composer-merge-plugin and RootAliasPackage only implemented those methods defined by the interface. Most of the unimplemented methods in RootAliasPackage can be worked around because the getter methods that are implemented proxy to the aliased package which we can modify by unwrapping. The exception being modifying the 'conflicts', 'provides' and 'replaces' collections. We have no way to actually modify those collections unfortunately in older versions of Composer. @param RootPackageInterface $root @param string $method Method needed @return RootPackageInterface|RootPackage
unwrapIfNeeded
php
wikimedia/composer-merge-plugin
src/ExtraPackage.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/ExtraPackage.php
MIT
public static function create(array $constraints, $conjunctive = true) { if (count($constraints) === 0) { // EmptyConstraint only exists in composer 1.x. Configure as to run phan against composer 2.x // @phan-suppress-next-line PhanTypeMismatchReturn, PhanUndeclaredClassMethod return new EmptyConstraint(); } if (count($constraints) === 1) { return $constraints[0]; } $optimized = self::optimizeConstraints($constraints, $conjunctive); if ($optimized !== null) { list($constraints, $conjunctive) = $optimized; if (count($constraints) === 1) { return $constraints[0]; } } return new self($constraints, $conjunctive); }
Tries to optimize the constraints as much as possible, meaning reducing/collapsing congruent constraints etc. Does not necessarily return a MultiConstraint instance if things can be reduced to a simple constraint @param ConstraintInterface[] $constraints A set of constraints @param bool $conjunctive Whether the constraints should be treated as conjunctive or disjunctive @return ConstraintInterface
create
php
wikimedia/composer-merge-plugin
src/MultiConstraint.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/MultiConstraint.php
MIT
public function getUpdateAllowList() { return array_keys($this->updateAllowList); }
Get list of packages to restrict update operations. @return string[] @see \Composer\Installer::setUpdateAllowList()
getUpdateAllowList
php
wikimedia/composer-merge-plugin
src/MergePlugin.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/MergePlugin.php
MIT
public function onInit(BaseEvent $event) { $this->state->loadSettings(); // It is not possible to know if the user specified --dev or --no-dev // so assume it is false. The dev section will be merged later when // the other events fire. $this->state->setDevMode(false); $this->mergeFiles($this->state->getIncludes(), false); $this->mergeFiles($this->state->getRequires(), true); }
Handle an event callback for initialization. @param BaseEvent $event
onInit
php
wikimedia/composer-merge-plugin
src/MergePlugin.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/MergePlugin.php
MIT
public function onInstallUpdateOrDump(ScriptEvent $event) { $this->state->loadSettings(); $this->state->setDevMode($event->isDevMode()); $this->mergeFiles($this->state->getIncludes(), false); $this->mergeFiles($this->state->getRequires(), true); if ($event->getName() === ScriptEvents::PRE_AUTOLOAD_DUMP) { $this->state->setDumpAutoloader(true); $flags = $event->getFlags(); if (isset($flags['optimize'])) { $this->state->setOptimizeAutoloader($flags['optimize']); } } }
Handle an event callback for an install, update or dump command by checking for "merge-plugin" in the "extra" data and merging package contents if found. @param ScriptEvent $event
onInstallUpdateOrDump
php
wikimedia/composer-merge-plugin
src/MergePlugin.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/MergePlugin.php
MIT
protected function mergeFile(RootPackageInterface $root, $path) { if (isset($this->loaded[$path]) || (isset($this->loadedNoDev[$path]) && !$this->state->isDevMode()) ) { $this->logger->debug( "Already merged <comment>$path</comment> completely" ); return; } $package = new ExtraPackage($path, $this->composer, $this->logger); if (isset($this->loadedNoDev[$path])) { $this->logger->info( "Loading -dev sections of <comment>{$path}</comment>..." ); $package->mergeDevInto($root, $this->state); } else { $this->logger->info("Loading <comment>{$path}</comment>..."); $package->mergeInto($root, $this->state); } $requirements = $package->getMergedRequirements(); if (!empty($requirements)) { $this->updateAllowList = array_replace( $this->updateAllowList, array_fill_keys($requirements, true) ); } if ($this->state->isDevMode()) { $this->loaded[$path] = true; } else { $this->loadedNoDev[$path] = true; } if ($this->state->recurseIncludes()) { $this->mergeFiles($package->getIncludes(), false); $this->mergeFiles($package->getRequires(), true); } }
Read a JSON file and merge its contents @param RootPackageInterface $root @param string $path
mergeFile
php
wikimedia/composer-merge-plugin
src/MergePlugin.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/MergePlugin.php
MIT
public function onPostPackageInstall(PackageEvent $event) { $op = $event->getOperation(); if ($op instanceof InstallOperation) { $package = $op->getPackage()->getName(); if ($package === self::PACKAGE_NAME) { $this->logger->info('composer-merge-plugin installed'); $this->state->setFirstInstall(true); $this->state->setLocked( $event->getComposer()->getLocker()->isLocked() ); } } }
Handle an event callback following installation of a new package by checking to see if the package that was installed was our plugin. @param PackageEvent $event
onPostPackageInstall
php
wikimedia/composer-merge-plugin
src/MergePlugin.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/MergePlugin.php
MIT
public function onPostInstallOrUpdate(ScriptEvent $event) { // @codeCoverageIgnoreStart if ($this->state->isFirstInstall()) { $this->state->setFirstInstall(false); $requirements = $this->getUpdateAllowList(); if (empty($requirements)) { return; } $this->logger->log("\n".'<info>Running composer update to apply merge settings</info>'); $lockBackup = null; $lock = null; if (!$this->state->isComposer1()) { $file = Factory::getComposerFile(); $lock = Factory::getLockFile($file); if (file_exists($lock)) { $lockBackup = file_get_contents($lock); } } $config = $this->composer->getConfig(); $preferSource = $config->get('preferred-install') === 'source'; $preferDist = $config->get('preferred-install') === 'dist'; $installer = Installer::create( $event->getIO(), // Create a new Composer instance to ensure full processing of // the merged files. Factory::create($event->getIO(), null, false) ); $installer->setPreferSource($preferSource); $installer->setPreferDist($preferDist); $installer->setDevMode($event->isDevMode()); $installer->setDumpAutoloader($this->state->shouldDumpAutoloader()); $installer->setOptimizeAutoloader( $this->state->shouldOptimizeAutoloader() ); $installer->setUpdate(true); if ($this->state->isComposer1()) { // setUpdateWhitelist() only exists in composer 1.x. Configure as to run phan against composer 2.x // @phan-suppress-next-line PhanUndeclaredMethod $installer->setUpdateWhitelist($requirements); } else { $installer->setUpdateAllowList($requirements); } $status = $installer->run(); if (( $status !== 0 ) && $lockBackup && $lock && !$this->state->isComposer1()) { $this->logger->log( "\n".'<error>'. 'Update to apply merge settings failed, reverting '.$lock.' to its original content.'. '</error>' ); file_put_contents($lock, $lockBackup); } } // @codeCoverageIgnoreEnd }
Handle an event callback following an install or update command. If our plugin was installed during the run then trigger an update command to process any merge-patterns in the current config. @param ScriptEvent $event
onPostInstallOrUpdate
php
wikimedia/composer-merge-plugin
src/MergePlugin.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/MergePlugin.php
MIT
protected function getStabilityInt($name) { $name = VersionParser::normalizeStability($name); return BasePackage::$stabilities[$name] ?? BasePackage::STABILITY_STABLE; }
Get the stability value for a given string. @param string $name Stability name @return int Stability value
getStabilityInt
php
wikimedia/composer-merge-plugin
src/StabilityFlags.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/StabilityFlags.php
MIT
protected function getExplicitStability($version) { $found = null; $constraints = $this->splitConstraints($version); foreach ($constraints as $constraint) { if (preg_match($this->explicitStabilityRe, $constraint, $match)) { $stability = $this->getStabilityInt($match[1]); $found = max($stability, $found); } } return $found; }
Extract the most unstable explicit stability (eg '@dev') from a version specification. @param string $version @return int|null Stability or null if no explict stability found
getExplicitStability
php
wikimedia/composer-merge-plugin
src/StabilityFlags.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/StabilityFlags.php
MIT
protected function getParsedStability($version) { // Drop aliasing if used $version = preg_replace('/^([^,\s@]+) as .+$/', '$1', $version); $stability = $this->getStabilityInt( VersionParser::parseStability($version) ); if ($stability === BasePackage::STABILITY_STABLE || $this->minimumStability > $stability ) { // Ignore if 'stable' or more stable than the global // minimum $stability = null; } return $stability; }
Get the stability of a version @param string $version @return int|null Stability or null if STABLE or less than minimum
getParsedStability
php
wikimedia/composer-merge-plugin
src/StabilityFlags.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/StabilityFlags.php
MIT
protected function getCurrentStability($name) { return $this->stabilityFlags[$name] ?? null; }
Get the current stability of a given package. @param string $name @return int|null Stability of null if not set
getCurrentStability
php
wikimedia/composer-merge-plugin
src/StabilityFlags.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/StabilityFlags.php
MIT
public function debug($message) { if ($this->inputOutput->isVeryVerbose()) { $message = " <info>[{$this->name}]</info> {$message}"; $this->log($message); } }
Log a debug message Messages will be output at the "very verbose" logging level (eg `-vv` needed on the Composer command). @param string $message
debug
php
wikimedia/composer-merge-plugin
src/Logger.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/Logger.php
MIT
public function info($message) { if ($this->inputOutput->isVerbose()) { $message = " <info>[{$this->name}]</info> {$message}"; $this->log($message); } }
Log an informative message Messages will be output at the "verbose" logging level (eg `-v` needed on the Composer command). @param string $message
info
php
wikimedia/composer-merge-plugin
src/Logger.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/Logger.php
MIT
public function isComposer1() { return $this->isComposer1; }
Test if this plugin runs within Composer 1. @return bool
isComposer1
php
wikimedia/composer-merge-plugin
src/PluginState.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/PluginState.php
MIT
public function getIncludes() { return $this->includes; }
Get list of filenames and/or glob patterns to include @return array
getIncludes
php
wikimedia/composer-merge-plugin
src/PluginState.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/PluginState.php
MIT
public function getRequires() { return $this->requires; }
Get list of filenames and/or glob patterns to require @return array
getRequires
php
wikimedia/composer-merge-plugin
src/PluginState.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/PluginState.php
MIT
public function isFirstInstall() { return $this->firstInstall; }
Is this the first time that the plugin has been installed? @return bool
isFirstInstall
php
wikimedia/composer-merge-plugin
src/PluginState.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/PluginState.php
MIT
public function isLocked() { return $this->locked; }
Was a lockfile present when the plugin was installed? @return bool
isLocked
php
wikimedia/composer-merge-plugin
src/PluginState.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/PluginState.php
MIT
public function isDevMode() { return $this->shouldMergeDev() && $this->devMode; }
Should devMode settings be processed? @return bool
isDevMode
php
wikimedia/composer-merge-plugin
src/PluginState.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/PluginState.php
MIT
public function shouldMergeDev() { return $this->mergeDev; }
Should devMode settings be merged? @return bool
shouldMergeDev
php
wikimedia/composer-merge-plugin
src/PluginState.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/PluginState.php
MIT
public function shouldDumpAutoloader() { return $this->dumpAutoloader; }
Is the autoloader file supposed to be written out? @return bool
shouldDumpAutoloader
php
wikimedia/composer-merge-plugin
src/PluginState.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/PluginState.php
MIT
public function setOptimizeAutoloader($flag) { $this->optimizeAutoloader = (bool)$flag; }
Set the optimizeAutoloader flag @param bool $flag
setOptimizeAutoloader
php
wikimedia/composer-merge-plugin
src/PluginState.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/PluginState.php
MIT
public function shouldOptimizeAutoloader() { return $this->optimizeAutoloader; }
Should the autoloader be optimized? @return bool
shouldOptimizeAutoloader
php
wikimedia/composer-merge-plugin
src/PluginState.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/PluginState.php
MIT
public function recurseIncludes() { return $this->recurse; }
Should includes be recursively processed? @return bool
recurseIncludes
php
wikimedia/composer-merge-plugin
src/PluginState.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/PluginState.php
MIT
public function replaceDuplicateLinks() { return $this->replace; }
Should duplicate links be replaced in a 'last definition wins' order? @return bool
replaceDuplicateLinks
php
wikimedia/composer-merge-plugin
src/PluginState.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/PluginState.php
MIT
public function ignoreDuplicateLinks() { return $this->ignore; }
Should duplicate links be ignored? @return bool
ignoreDuplicateLinks
php
wikimedia/composer-merge-plugin
src/PluginState.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/PluginState.php
MIT
public function shouldMergeExtra() { return $this->mergeExtra; }
Should the extra section be merged? By default, the extra section is not merged and there will be many cases where the merge of the extra section is performed too late to be of use to other plugins. When enabled, merging uses one of two strategies - either 'first wins' or 'last wins'. When enabled, 'first wins' is the default behaviour. If Replace mode is activated then 'last wins' is used. @return bool
shouldMergeExtra
php
wikimedia/composer-merge-plugin
src/PluginState.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/PluginState.php
MIT
public function shouldMergeExtraDeep() { return $this->mergeExtraDeep; }
Should the extra section be merged deep / recursively? By default the extra section is merged with array_merge() and duplicate keys are ignored. When enabled this allows to merge the arrays recursively using the following rule: Integer keys are merged, while array values are replaced where the later values overwrite the former. This is useful especially for the extra section when plugins use larger structures like a 'patches' key with the packages as sub-keys and the patches as values. When 'replace' mode is activated the order of array merges is exchanged. @return bool
shouldMergeExtraDeep
php
wikimedia/composer-merge-plugin
src/PluginState.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/PluginState.php
MIT
public function shouldMergeReplace() { return $this->mergeReplace; }
Should the replace section be merged? By default, the replace section is merged. @return bool
shouldMergeReplace
php
wikimedia/composer-merge-plugin
src/PluginState.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/PluginState.php
MIT
public function shouldMergeScripts() { return $this->mergeScripts; }
Should the scripts section be merged? By default, the scripts section is not merged. @return bool
shouldMergeScripts
php
wikimedia/composer-merge-plugin
src/PluginState.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/src/PluginState.php
MIT
public function provideFireInit() { return [ "with INIT event" => [true], "without INIT event" => [true], ]; }
Generic provider for tests that should be tried with and without an INIT event.
provideFireInit
php
wikimedia/composer-merge-plugin
tests/phpunit/MergePluginTest.php
https://github.com/wikimedia/composer-merge-plugin/blob/master/tests/phpunit/MergePluginTest.php
MIT
protected function updateProfileInInvoiceObject() { $profileDef = ZugferdProfileResolver::resolveProfileDefById($this->convertToProfileId); $this->getObjectHelper()->tryCallByPath( $this->getInvoiceObject(), static::PATH_1, $this->getObjectHelper()->getIdType($profileDef['contextparameter']) ); if ($profileDef['businessprocess']) { $this->getObjectHelper()->tryCallByPath( $this->getInvoiceObject(), static::PATH_2, $this->getObjectHelper()->createClassInstance('ram\DocumentContextParameterType') ); $this->getObjectHelper()->tryCallByPath( $this->getInvoiceObject(), static::PATH_3, $this->getObjectHelper()->getIdType($profileDef['businessprocess']) ); } }
Update profile parameters in the internal invoice object @return void @throws ZugferdUnknownProfileIdException
updateProfileInInvoiceObject
php
horstoeko/zugferd
src/ZugferdDocumentProfileConverter.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentProfileConverter.php
MIT
public function __construct(string $xmlDataOrFilename, string $pdfData) { $this->xmlDataOrFilename = $xmlDataOrFilename; parent::__construct($pdfData); }
Constructor @param string $xmlDataOrFilename The XML data as a string or the full qualified path to an XML-File containing the XML-data @param string $pdfData The full filename or a string containing the binary pdf data. This is the original PDF (e.g. created by a ERP system)
__construct
php
horstoeko/zugferd
src/ZugferdDocumentPdfMerger.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentPdfMerger.php
MIT
private function getProfileDefinitionParameter(string $parameterName) { $profileDefinition = $this->getProfileDefinition(); if (isset($profileDefinition[$parameterName])) { return $profileDefinition[$parameterName]; } throw new ZugferdUnknownProfileParameterException($parameterName); }
Get a parameter from profile definition @param string $parameterName @return mixed @throws ZugferdFileNotReadableException @throws ZugferdUnknownXmlContentException @throws ZugferdUnknownProfileException @throws ZugferdUnknownProfileParameterException
getProfileDefinitionParameter
php
horstoeko/zugferd
src/ZugferdDocumentPdfMerger.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentPdfMerger.php
MIT
private function getInvoiceValueByPath(string $methods, $defaultValue) { return $this->getInvoiceValueByPathFrom($this->getInvoiceObject(), $methods, $defaultValue); }
Function to return a value from $invoiceObject by path @param string $methods @param mixed $defaultValue @return mixed
getInvoiceValueByPath
php
horstoeko/zugferd
src/ZugferdDocumentReader.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentReader.php
MIT
private function getInvoiceValueByPathFrom(?object $from, string $methods, $defaultValue) { return $this->getObjectHelper()->tryCallByPathAndReturn($from, $methods) ?? $defaultValue; }
Function to return a value from $from by path @param object|null $from @param string $methods @param mixed $defaultValue @return mixed
getInvoiceValueByPathFrom
php
horstoeko/zugferd
src/ZugferdDocumentReader.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentReader.php
MIT
public function __toString() { return $this->getContent(); }
Receive the content as XML string @return string @see https://www.php.net/manual/en/language.oop5.magic.php#object.tostring
__toString
php
horstoeko/zugferd
src/ZugferdDocumentBuilder.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentBuilder.php
MIT
protected function onBeforeGetContent() { // Do nothing }
This method can be overridden in derived class It is called before a XML is written @return void
onBeforeGetContent
php
horstoeko/zugferd
src/ZugferdDocumentBuilder.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentBuilder.php
MIT
public function getCrossIndustryInvoice() { $crossIndustryInvoice = $this->createClassInstance('rsm\CrossIndustryInvoice'); $crossIndustryInvoice->setExchangedDocumentContext($this->createClassInstance('ram\ExchangedDocumentContextType')); $crossIndustryInvoice->setExchangedDocument($this->createClassInstance('ram\ExchangedDocumentType')); $crossIndustryInvoice->setSupplyChainTradeTransaction($this->createClassInstance('ram\SupplyChainTradeTransactionType')); $crossIndustryInvoice->getExchangedDocumentContext()->setGuidelineSpecifiedDocumentContextParameter($this->createClassInstance('ram\DocumentContextParameterType')); $crossIndustryInvoice->getExchangedDocumentContext()->getGuidelineSpecifiedDocumentContextParameter()->setID($this->getIdType($this->profiledef['contextparameter'])); if ($this->profiledef['businessprocess']) { $crossIndustryInvoice->getExchangedDocumentContext()->setBusinessProcessSpecifiedDocumentContextParameter($this->createClassInstance('ram\DocumentContextParameterType')); $crossIndustryInvoice->getExchangedDocumentContext()->getBusinessProcessSpecifiedDocumentContextParameter()->setID($this->getIdType($this->profiledef['businessprocess'])); } $crossIndustryInvoice->getSupplyChainTradeTransaction()->setApplicableHeaderTradeAgreement($this->createClassInstance('ram\HeaderTradeAgreementType')); $crossIndustryInvoice->getSupplyChainTradeTransaction()->setApplicableHeaderTradeDelivery($this->createClassInstance('ram\HeaderTradeDeliveryType')); $crossIndustryInvoice->getSupplyChainTradeTransaction()->setApplicableHeaderTradeSettlement($this->createClassInstance('ram\HeaderTradeSettlementType')); return $crossIndustryInvoice; }
Return the main invoice object @return \horstoeko\zugferd\entities\basic\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\basicwl\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\en16931\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\extended\rsm\CrossIndustryInvoice
getCrossIndustryInvoice
php
horstoeko/zugferd
src/ZugferdObjectHelper.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdObjectHelper.php
MIT
public function tryCallAndReturn($instance, string $method) { if (!$instance) { return null; } if ($method === '') { return null; } if ($this->methodExists($instance, $method)) { return $instance->$method(); } return null; }
Tries to call a method and return the returnvalue from call to $method in object $instance @param object $instance @param string $method @return mixed
tryCallAndReturn
php
horstoeko/zugferd
src/ZugferdObjectHelper.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdObjectHelper.php
MIT
public function tryCallByPath($instance, string $methods, $value) { $methods = explode(".", $methods); foreach ($methods as $index => $method) { if ($index == count($methods) - 1) { $this->tryCall($instance, $method, $value); } else { $instance = $this->tryCallAndReturn($instance, $method); } } }
Try call methods in a form .object.method1.method2.method3 @param object $instance @param string $methods @param mixed $value @return void
tryCallByPath
php
horstoeko/zugferd
src/ZugferdObjectHelper.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdObjectHelper.php
MIT
public static function isNullOrEmpty($value) { if ($value === null) { return true; } return !is_object($value) && (string)$value === ""; }
Test if a value is null or empty @param mixed $value @return boolean
isNullOrEmpty
php
horstoeko/zugferd
src/ZugferdObjectHelper.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdObjectHelper.php
MIT
public function toPrettyJsonString() { return json_encode($this->toJsonObject(), JSON_PRETTY_PRINT); }
Returns the invoice object as a pretty printed json string @return string|boolean
toPrettyJsonString
php
horstoeko/zugferd
src/ZugferdDocumentJsonExporter.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentJsonExporter.php
MIT
public function __construct(string $pdfData) { $this->pdfData = $pdfData; $this->pdfWriter = new ZugferdPdfWriter(); }
Constructor @param string $pdfData The full filename or a string containing the binary pdf data. This is the original PDF (e.g. created by a ERP system)
__construct
php
horstoeko/zugferd
src/ZugferdDocumentPdfBuilderAbstract.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentPdfBuilderAbstract.php
MIT
public function saveDocument(string $toFilename) { $this->pdfWriter->Output('F', $toFilename); return $this; }
Saves the generated PDF document to a file @param string $toFilename The full qualified filename to which the generated PDF (with attachment)is stored @return static
saveDocument
php
horstoeko/zugferd
src/ZugferdDocumentPdfBuilderAbstract.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentPdfBuilderAbstract.php
MIT
public function setAdditionalCreatorTool(string $additionalCreatorTool) { $this->additionalCreatorTool = $additionalCreatorTool; return $this; }
Sets an additional creator tool (e.g. the ERP software that called the PHP library) @param string $additionalCreatorTool The name of the creator @return static
setAdditionalCreatorTool
php
horstoeko/zugferd
src/ZugferdDocumentPdfBuilderAbstract.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentPdfBuilderAbstract.php
MIT
public function setAttachmentRelationshipType(string $relationshipType) { if (!in_array($relationshipType, [static::AF_RELATIONSHIP_DATA, static::AF_RELATIONSHIP_ALTERNATIVE, static::AF_RELATIONSHIP_SOURCE])) { $relationshipType = static::AF_RELATIONSHIP_DATA; } $this->attachmentRelationshipType = $relationshipType; return $this; }
Set the type of relationship for the XML attachment. Allowed types are 'Data', 'Alternative' and 'Source' @param string $relationshipType Type of relationship @return static
setAttachmentRelationshipType
php
horstoeko/zugferd
src/ZugferdDocumentPdfBuilderAbstract.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentPdfBuilderAbstract.php
MIT
public function setAttachmentRelationshipTypeToData() { return $this->setAttachmentRelationshipType(static::AF_RELATIONSHIP_DATA); }
Set the type of relationship for the XML attachment to "Data" @return static
setAttachmentRelationshipTypeToData
php
horstoeko/zugferd
src/ZugferdDocumentPdfBuilderAbstract.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentPdfBuilderAbstract.php
MIT
public function setAttachmentRelationshipTypeToAlternative() { return $this->setAttachmentRelationshipType(static::AF_RELATIONSHIP_ALTERNATIVE); }
Set the type of relationship for the XML attachment to "Alternative" @return static
setAttachmentRelationshipTypeToAlternative
php
horstoeko/zugferd
src/ZugferdDocumentPdfBuilderAbstract.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentPdfBuilderAbstract.php
MIT
public function setAttachmentRelationshipTypeToSource() { return $this->setAttachmentRelationshipType(static::AF_RELATIONSHIP_SOURCE); }
Set the type of relationship for the XML attachment to "Source" @return static
setAttachmentRelationshipTypeToSource
php
horstoeko/zugferd
src/ZugferdDocumentPdfBuilderAbstract.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentPdfBuilderAbstract.php
MIT
public function attachAdditionalFileByRealFile(string $fullFilename, string $displayName = "", string $relationshipType = "") { // Checks that the file really exists if ($fullFilename === '') { throw new ZugferdInvalidArgumentException("You must specify a filename for the content to attach"); } if (!file_exists($fullFilename)) { throw new ZugferdFileNotFoundException($fullFilename); } // Load content $content = file_get_contents($fullFilename); if ($content === false) { throw new ZugferdFileNotReadableException($fullFilename); } // Add attachment $this->attachAdditionalFileByContent( $content, $fullFilename, $displayName, $relationshipType, ); return $this; }
Attach an additional file to PDF. The file that is specified in $fullFilename must exists @param string $fullFilename @param string $displayName @param string $relationshipType @return static @throws ZugferdInvalidArgumentException @throws ZugferdFileNotFoundException @throws ZugferdFileNotReadableException @throws ZugferdUnknownMimetype
attachAdditionalFileByRealFile
php
horstoeko/zugferd
src/ZugferdDocumentPdfBuilderAbstract.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentPdfBuilderAbstract.php
MIT
public function attachAdditionalFileByContent(string $content, string $filename, string $displayName = "", string $relationshipType = "") { // Check content. The content must not be empty if ($content === '') { throw new ZugferdInvalidArgumentException("You must specify a content to attach"); } // Check filename. The filename must not be empty if ($filename === '') { throw new ZugferdInvalidArgumentException("You must specify a filename for the content to attach"); } // Mimetype for the file must exist $mimeType = (new MimeDb())->findFirstMimeTypeByExtension(FileUtils::getFileExtension($filename)); if (is_null($mimeType)) { throw new ZugferdUnknownMimetype(); } // Sanatize relationship type if ($relationshipType === '') { $relationshipType = static::AF_RELATIONSHIP_SUPPLEMENT; } if (!in_array($relationshipType, [static::AF_RELATIONSHIP_DATA, static::AF_RELATIONSHIP_ALTERNATIVE, static::AF_RELATIONSHIP_SOURCE, static::AF_RELATIONSHIP_SUPPLEMENT, static::AF_RELATIONSHIP_UNSPECIFIED])) { $relationshipType = static::AF_RELATIONSHIP_SUPPLEMENT; } // Sanatize displayname if ($displayName === '') { $displayName = FileUtils::getFilenameWithExtension($filename); } // Add to attachment list $this->additionalFilesToAttach[] = [ PdfStreamReader::createByString($content), FileUtils::getFilenameWithExtension($filename), $displayName, $relationshipType, str_replace('/', '#2F', $mimeType) ]; return $this; }
Attach an additional file to PDF by a content string @param string $content @param string $filename @param string $displayName @param string $relationshipType @return static @throws ZugferdInvalidArgumentException @throws ZugferdUnknownMimetype
attachAdditionalFileByContent
php
horstoeko/zugferd
src/ZugferdDocumentPdfBuilderAbstract.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentPdfBuilderAbstract.php
MIT
public function setDeterministicModeEnabled(bool $deterministicModeEnabled) { $this->pdfWriter->setDeterministicModeEnabled($deterministicModeEnabled); return $this; }
Set the the deterministic mode. This mode should only be used for testing purposes @param bool $deterministicModeEnabled @return static
setDeterministicModeEnabled
php
horstoeko/zugferd
src/ZugferdDocumentPdfBuilderAbstract.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentPdfBuilderAbstract.php
MIT
public function setAuthorTemplate(string $authorTemplate) { $this->authorTemplate = $authorTemplate; return $this; }
Set the template for the author meta information @param string $authorTemplate @return static
setAuthorTemplate
php
horstoeko/zugferd
src/ZugferdDocumentPdfBuilderAbstract.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentPdfBuilderAbstract.php
MIT
public function setKeywordTemplate(string $keywordTemplate) { $this->keywordTemplate = $keywordTemplate; return $this; }
Set the template for the keyword meta information @param string $keywordTemplate @return static
setKeywordTemplate
php
horstoeko/zugferd
src/ZugferdDocumentPdfBuilderAbstract.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentPdfBuilderAbstract.php
MIT
public function setTitleTemplate(string $titleTemplate) { $this->titleTemplate = $titleTemplate; return $this; }
Set the template for the title meta information @param string $titleTemplate @return static
setTitleTemplate
php
horstoeko/zugferd
src/ZugferdDocumentPdfBuilderAbstract.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentPdfBuilderAbstract.php
MIT
public function setSubjectTemplate(string $subjectTemplate) { $this->subjectTemplate = $subjectTemplate; return $this; }
Set the template for the subject meta information @param string $subjectTemplate @return static
setSubjectTemplate
php
horstoeko/zugferd
src/ZugferdDocumentPdfBuilderAbstract.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentPdfBuilderAbstract.php
MIT
public function setMetaInformationCallback(?callable $callback = null) { $this->metaInformationCallback = is_callable($callback) ? $callback : null; return $this; }
Set the user defined callback for generating custom meta information @param callable|null $callback @return static
setMetaInformationCallback
php
horstoeko/zugferd
src/ZugferdDocumentPdfBuilderAbstract.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocumentPdfBuilderAbstract.php
MIT
protected function getInvoiceObject() { return $this->invoiceObject; }
Returns the internal invoice object (created by the serializer). This is used e.g. in the validator @return \horstoeko\zugferd\entities\basic\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\basicwl\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\en16931\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\extended\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\minimum\rsm\CrossIndustryInvoice
getInvoiceObject
php
horstoeko/zugferd
src/ZugferdDocument.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocument.php
MIT
protected function createInvoiceObject() { $this->invoiceObject = $this->getObjectHelper()->getCrossIndustryInvoice(); return $this->invoiceObject; }
Create a new instance of the internal invoice object @return \horstoeko\zugferd\entities\basic\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\basicwl\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\en16931\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\extended\rsm\CrossIndustryInvoice|\horstoeko\zugferd\entities\minimum\rsm\CrossIndustryInvoice
createInvoiceObject
php
horstoeko/zugferd
src/ZugferdDocument.php
https://github.com/horstoeko/zugferd/blob/master/src/ZugferdDocument.php
MIT