Skip to content

Commit

Permalink
Logging tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
chevli committed Sep 11, 2016
1 parent 1eaac44 commit dae6cd2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Model/Component/Websites.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ protected function canParseAndProcess()
protected function parseData($source = null)
{
try {
if ($source == null) {
throw new ComponentException(
sprintf('The %s component requires to have a file source definition.', $this->alias)
);
}

$parser = new Yaml();
return $parser->parse(file_get_contents($source));
} catch (ComponentException $e) {
Expand Down Expand Up @@ -93,7 +99,7 @@ protected function processWebsite($code, $websiteData)
try {

// Load website via ObjectManager
$this->log->logQuestion(sprintf("Does the the website with code '%s' already exist?", $code), $logNest);
$this->log->logQuestion(sprintf("Does the website with code '%s' already exist?", $code), $logNest);
$websiteFactory = new WebsiteFactory($this->objectManager, \Magento\Store\Model\Website::class);
$website = $websiteFactory->create();
$website->load($code, 'code');
Expand All @@ -102,6 +108,7 @@ protected function processWebsite($code, $websiteData)

// Check if it exists
if ($website->getId()) {
$this->log->logInfo("Yes",$logNest);
$this->log->logComment(sprintf("Website already exists with code '%s'", $code), $logNest);
} else {

Expand Down Expand Up @@ -185,6 +192,7 @@ protected function processStoreGroup($storeGroupData, Website $website)

// Check if the store group already exists
if ($storeGroup->getId()) {
$this->log->logInfo("Yes",$logNest);
$this->log->logComment(
sprintf("Store group already exists with name '%s'", $storeGroupData['name']),
$logNest
Expand Down Expand Up @@ -254,6 +262,7 @@ protected function processStoreView($code, $storeViewData, Group $storeGroup)

// Check if it exists
if ($storeView->getId()) {
$this->log->logInfo("Yes",$logNest);
$this->log->logComment(sprintf("Store view already exists with code '%s'", $code), $logNest);
} else {

Expand Down
9 changes: 9 additions & 0 deletions Model/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use CtiDigital\Configurator\Model\Configurator\ConfigInterface;
use CtiDigital\Configurator\Model\Exception\ComponentException;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Profiler\Driver\Standard\OutputInterface;
use Symfony\Component\Yaml\Parser;

class Processor
Expand Down Expand Up @@ -113,6 +114,8 @@ public function run()
$masterPath = BP . '/app/etc/master.yaml';
if (!file_exists($masterPath)) {
throw new ComponentException("Master YAML does not exist. Please create one in $masterPath");
} else {
$this->log->logComment(sprintf("Found Master YAML"));
}
$yamlContents = file_get_contents($masterPath);
$yaml = new Parser();
Expand All @@ -126,6 +129,8 @@ public function run()
// Loop through components and run them individually in the master.yaml order
foreach ($master as $componentAlias => $componentConfig) {

$this->log->logComment(sprintf("Loading component %s", $componentAlias));

$componentClass = $this->configInterface->getComponentByName($componentAlias);

/* @var ComponentAbstract $component */
Expand Down Expand Up @@ -191,7 +196,11 @@ public function run()
*/
private function isValidComponent($componentName)
{
if ($this->log->getLogLevel() > \Symfony\Component\Console\Output\OutputInterface::VERBOSITY_NORMAL) {
$this->log->logQuestion(sprintf("Does the %s component exist?", $componentName));
}
$componentClass = $this->configInterface->getComponentByName($componentName);
$this->log->logComment(sprintf("The %s component has %s class name.", $componentName, $componentClass));
$component = $this->objectManager->create($componentClass);
if ($component instanceof ComponentAbstract) {
return true;
Expand Down

0 comments on commit dae6cd2

Please sign in to comment.