Skip to content

Commit

Permalink
Hello, World!
Browse files Browse the repository at this point in the history
  • Loading branch information
niksamokhvalov committed Jan 8, 2016
0 parents commit 191875c
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/
composer.lock
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sudo: false

language: php

php:
- 5.4
- 5.5
- 5.6

script:
- composer self-update
- composer install --prefer-source --no-interaction
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright © 2016 Notamedia Ltd. (http://nota.media)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Empty file added README.md
Empty file.
18 changes: 18 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "notamedia/console-jedi",
"description": "Console application for CMS Bitrix",
"keywords": ["bitrix", "console", "application"],
"type": "library",
"license": "MIT",
"support": {
"issues": "https://github.com/notamedia/console-jedi/issues",
"source": "https://github.com/notamedia/console-jedi/"
},
"require": {
"php": ">=5.4",
"symfony/console": "~v2.8"
},
"autoload": {
"psr-4": {"Notamedia\\ConsoleJedi\\": "src/"}
}
}
38 changes: 38 additions & 0 deletions src/Command/Agents/OnCronCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* @link https://github.com/notamedia/console-jedi
* @copyright Copyright © 2016 Notamedia Ltd.
* @license MIT
*/

namespace Notamedia\ConsoleJedi\Command\Agents;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Installation configurations for run Agents on cron.
*/
class OnCronCommand extends Command
{
/**
* {@inheritdoc}
*/
protected function configure()
{
parent::configure();

$this->setName('agents:on-cron')
->setDescription('Installation configurations for run Agents on cron');
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
\COption::SetOptionString('main', 'agents_use_crontab', 'N');
\COption::SetOptionString('main', 'check_agents', 'N');
}
}
72 changes: 72 additions & 0 deletions src/Command/Cache/ClearCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/**
* @link https://github.com/notamedia/console-jedi
* @copyright Copyright © 2016 Notamedia Ltd.
* @license MIT
*/

namespace Notamedia\ConsoleJedi\Command\Cache;

use Bitrix\Main\Application;
use Bitrix\Main\Data\Cache;
use Bitrix\Main\Data\StaticHtmlCache;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Command for clear Bitrix cache.
*/
class ClearCommand extends Command
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this->setName('cache:clear')
->setDescription('Clear all cache')
->addOption('dir', 'd', InputOption::VALUE_REQUIRED, 'Clear cache only for directory (relative from /' . BX_ROOT . '/cache/)')
->addOption('tag', 't', InputOption::VALUE_REQUIRED, 'Clear cache by tag');
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$dir = $input->getOption('dir');
$tag = $input->getOption('tag');
$cache = Cache::createInstance();

if (empty($dir) && empty($tag))
{
Application::getInstance()->getManagedCache()->cleanAll();
$cache->CleanDir();
$cache->CleanDir(false, 'stack_cache');
StaticHtmlCache::getInstance()->deleteAll();

if (Cache::clearCache(true))
{
$output->writeln('<info>All Bitrix cache was deleted</info>');
}
else
{
$output->writeln('<error>Error deleting Bitrix cache</error>');
}
}

if ($dir)
{
$cache->CleanDir($dir);
$output->writeln('<info>Bitrix cache by "/' . BX_ROOT . '/cache/' . $dir . '" dir was deleted</info>');
}

if ($tag)
{
Application::getInstance()->getTaggedCache()->ClearByTag($tag);
$output->writeln('<info>Bitrix cache by tag "' . $tag . '" was deleted</info>');
}
}
}

0 comments on commit 191875c

Please sign in to comment.