Skip to content

Commit

Permalink
Added some convenience methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bobvandevijver committed Feb 25, 2018
1 parent b4aa720 commit 7498cf4
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 18 deletions.
2 changes: 0 additions & 2 deletions Latex/Base/Standalone.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ class Standalone extends LatexBase
* Article constructor, sets defaults
*
* @param string $filename
*
* @throws \BobV\LatexBundle\Exception\LatexException
*/
public function __construct($filename) {
// Define standard values
Expand Down
51 changes: 42 additions & 9 deletions Latex/LatexBase.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace BobV\LatexBundle\Latex;

use BobV\LatexBundle\Exception\LatexException;
Expand All @@ -16,8 +17,6 @@ class LatexBase extends LatexParams implements LatexBaseInterface

/**
* @param string $filename
*
* @throws \BobV\LatexBundle\Exception\LatexException
*/
public function __construct($filename)
{
Expand Down Expand Up @@ -81,7 +80,7 @@ public function getFileName()
/**
* @param string $fileName
*
* @return LatexInterface $this
* @return LatexBaseInterface $this
*/
public function setFileName($fileName)
{
Expand All @@ -101,7 +100,7 @@ public function getTemplate()
/**
* @param string $template
*
* @return LatexInterface $this
* @return LatexBaseInterface $this
*/
public function setTemplate($template)
{
Expand All @@ -113,28 +112,46 @@ public function setTemplate($template)
/**
* @return array
*/
public function getDependencies(){
public function getDependencies()
{
return $this->dependencies;
}

/**
* @param $dependency
*
* @return LatexInterface $this
* @return LatexBaseInterface $this
*/
public function addDependency($dependency){
public function addDependency($dependency)
{
$this->dependencies[] = $dependency;

return $this;
}

/**
* To add multiple dependencies locations
*
* @param $dependencies
*
* @return LatexBaseInterface
*/
public function addDependencies($dependencies)
{
foreach ($dependencies as $dependency) {
$this->addDependency($dependency);
}

return $this;
}

/**
* Add an package to include
*
* @param $package
* @param $options
*
* @return LatexInterface $this
* @return LatexBaseInterface $this
*/
public function addPackage($package, $options = '')
{
Expand All @@ -146,9 +163,25 @@ public function addPackage($package, $options = '')

$this->params['packages'][] = array(
'p' => $package,
'o' => $options
'o' => $options,
);

return $this;
}

/**
* Add multiple packages to include (without options)
*
* @param $packages
*
* @return mixed
*/
public function addPackages($packages)
{
foreach ($packages as $package) {
$this->addPackage($package);
}

return $this;
}
}
38 changes: 34 additions & 4 deletions Latex/LatexBaseInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace BobV\LatexBundle\Latex;

interface LatexBaseInterface extends LatexInterface
Expand All @@ -22,7 +23,7 @@ public function getFileName();
*
* @param string $fileName
*
* @return LatexInterface
* @return LatexBaseInterface
*/
public function setFileName($fileName);

Expand All @@ -36,9 +37,38 @@ public function getDependencies();
/**
* To add an dependency location
*
* @param $depedency
* @param $dependency
*
* @return LatexInterface
* @return LatexBaseInterface
*/
public function addDependency($depedency);
public function addDependency($dependency);

/**
* To add multiple dependencies locations
*
* @param $dependencies
*
* @return LatexBaseInterface
*/
public function addDependencies($dependencies);

/**
* Add an package to include
*
* @param $package
* @param $options
*
* @return LatexBaseInterface $this
*/
public function addPackage($package, $options = '');

/**
* Add multiple packages to include (without options)
*
* @param $packages
*
* @return mixed
*/
public function addPackages($packages);

}
6 changes: 5 additions & 1 deletion Resources/doc/base/Article.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ new Article($filename)

This class also has an `addPackage($package, $options = '')` method. Use this if you need to include extra packages.

As convenience, multiple packages can be added with a single invocation of `addPackages($packages)`. However, this is without package options.

### Add dependency

This class also has an `addDependency($dependency)` method. Use this if you need to copy files from a certain dir to the compilation dir.

As convenience, multiple dependencies can be added with a single invocation of `addDependencies($dependencies)`.

### Template

See [here](https://github.com/bobvandevijver/latex-bundle/blob/master/Resources/views/Base/article.tex.twig).
See [here](https://github.com/bobvandevijver/latex-bundle/blob/master/Resources/views/Base/article.tex.twig).
6 changes: 5 additions & 1 deletion Resources/doc/base/Book.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@ new Book($filename)

This class also has an `addPackage($package, $options = '')` method. Use this if you need to include extra packages.

As convenience, multiple packages can be added with a single invocation of `addPackages($packages)`. However, this is without package options.

### Add dependency

This class also has an `addDependency($dependency)` method. Use this if you need to copy files from a certain dir to the compilation dir.

As convenience, multiple dependencies can be added with a single invocation of `addDependencies($dependencies)`.

### Template

See [here](https://github.com/bobvandevijver/latex-bundle/blob/master/Resources/views/Base/book.tex.twig).
See [here](https://github.com/bobvandevijver/latex-bundle/blob/master/Resources/views/Base/book.tex.twig).
6 changes: 5 additions & 1 deletion Resources/doc/base/Letter.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ new Letter($filename)

This class also has an `addPackage($package, $options = '')` method. Use this if you need to include extra packages.

As convenience, multiple packages can be added with a single invocation of `addPackages($packages)`. However, this is without package options.

### Add dependency

This class also has an `addDependency($dependency)` method. Use this if you need to copy files from a certain dir to the compilation dir.

As convenience, multiple dependencies can be added with a single invocation of `addDependencies($dependencies)`.

### Template

See [here](https://github.com/bobvandevijver/latex-bundle/blob/master/Resources/views/Base/letter.tex.twig).
See [here](https://github.com/bobvandevijver/latex-bundle/blob/master/Resources/views/Base/letter.tex.twig).
4 changes: 4 additions & 0 deletions Resources/doc/base/Standalone.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ new Standalone($filename)

This class also has an `addPackage($package, $options = '')` method. Use this if you need to include extra packages.

As convenience, multiple packages can be added with a single invocation of `addPackages($packages)`. However, this is without package options.

### Add dependency

This class also has an `addDependency($dependency)` method. Use this if you need to copy files from a certain dir to the compilation dir.

As convenience, multiple dependencies can be added with a single invocation of `addDependencies($dependencies)`.

### Template

See [here](https://github.com/bobvandevijver/latex-bundle/blob/master/Resources/views/Base/standalone.tex.twig).

0 comments on commit 7498cf4

Please sign in to comment.