Skip to content

Api #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

Api #47

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions src/Tasks/Build/Api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php
/**
* @package JoRobo
*
* @copyright Copyright (C) 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Jorobo\Tasks\Build;

use Robo\Result;
use Robo\Task\BaseTask;
use Robo\Contract\TaskInterface;
use Robo\Exception\TaskException;

use Joomla\Jorobo\Tasks\JTask;

/**
* Build Api
*
* @package Joomla\Jorobo\Tasks\Build
*
* @since 1.0
*/
class Api extends Base implements TaskInterface
{
use \Robo\Task\Development\loadTasks;
use \Robo\Common\TaskIO;

protected $source = null;

protected $target = null;

protected $fileMap = null;

/**
* Initialize Build Task
*
* @since 1.0
*/
public function __construct()
{
parent::__construct();

$this->source = $this->getSourceFolder() . "/api";
$this->target = $this->getBuildFolder() . "/api";
}

/**
* Runs the api build tasks, just copying files currently
*
* @return boolean
*
* @since 1.0
*/
public function run()
{
$this->say("Copying API files " . $this->source);

if (!file_exists($this->source))
{
$this->say("Folder " . $this->source . " does not exist!");

return true;
}

$this->prepareDirectory();

$map = $this->copyTarget($this->source, $this->target);

$this->setResultFiles($map);

return true;
}

/**
* Prepare the directory structure
*
* @return void
*
* @since 1.0
*/
private function prepareDirectory()
{
$this->_mkdir($this->target);
}
}
1 change: 1 addition & 0 deletions src/Tasks/Build/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ public function resetFiles()
self::$frontendFiles = array();
self::$frontendLanguageFiles = array();
self::$mediaFiles = array();
self::$apiFiles = array();
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/Tasks/Build/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ public function run()
$this->buildCli()->run();
}

// Api
if ($this->hasApi)
{
$this->buildApi()->run();
}

// Update XML and script.php
$this->createInstaller();

Expand Down
12 changes: 12 additions & 0 deletions src/Tasks/Build/buildTasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ protected function buildCli()
return new Cli;
}

/**
* Build api folder
*
* @return Api
*
* @since 1.0
*/
protected function buildApi()
{
return new Api;
}

/**
* Build a Module
*
Expand Down
16 changes: 16 additions & 0 deletions src/Tasks/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,22 @@ private function linkSubdirectories($src, $to)
}
}

/**
* Process Api
*
* @param String $src The source
* @param String $toDir The target
*
* @return void
*
* @since 1.0
*/
private function processApi($src, $toDir)
{
$sourceFolder = $this->getSourceFolder();
$this->processComponents($sourceFolder . '/api/components', $this->target . '/api');
}

/**
* Process Cli
*
Expand Down