├── .php_cs
├── .travis.yml
├── autoload.php
├── build
├── ci
│ ├── beanstalkd.sh
│ ├── build.sh
│ └── script.sh
└── clarity.sh
├── codecept
├── _bootstrap.php
├── _data
│ └── dump.sql
├── _support
│ ├── AcceptanceTester.php
│ ├── FunctionalTester.php
│ ├── Helper
│ │ ├── Acceptance.php
│ │ ├── Functional.php
│ │ └── Unit.php
│ ├── UnitTester.php
│ └── _generated
│ │ ├── AcceptanceTesterActions.php
│ │ ├── FunctionalTesterActions.php
│ │ └── UnitTesterActions.php
├── acceptance.suite.yml
├── acceptance
│ └── _bootstrap.php
├── functional.suite.yml
├── functional
│ └── _bootstrap.php
├── unit.suite.yml
└── unit
│ ├── MailTest.php
│ ├── TranslationTest.php
│ ├── ValidatorTest.php
│ ├── _bootstrap.php
│ └── resources
│ └── lang
│ └── en
│ ├── folder
│ └── site.php
│ └── simple.php
├── codeception.yml
├── composer.json
├── contributing.md
├── php-cs-fixer
├── phpunit.xml
├── readme.md
├── src
└── Clarity
│ ├── Console
│ ├── App
│ │ ├── ControllerCommand.php
│ │ ├── ModuleCommand.php
│ │ ├── RouteCommand.php
│ │ └── stubs
│ │ │ ├── controller
│ │ │ ├── controller.stub
│ │ │ └── functions.stub
│ │ │ ├── module
│ │ │ ├── base_controller.stub
│ │ │ ├── base_route.stub
│ │ │ ├── base_route_provider.stub
│ │ │ └── index.stub
│ │ │ └── route
│ │ │ ├── functions.stub
│ │ │ └── route.stub
│ ├── Brood.php
│ ├── CLI.php
│ ├── Clear
│ │ ├── AllCommand.php
│ │ ├── CacheCommand.php
│ │ ├── ClearTrait.php
│ │ ├── CompiledCommand.php
│ │ ├── LogsCommand.php
│ │ ├── SessionCommand.php
│ │ └── ViewsCommand.php
│ ├── DB
│ │ ├── AbstractCommand.php
│ │ ├── Create.php
│ │ ├── Migrate.php
│ │ ├── Rollback.php
│ │ ├── SeedCreate.php
│ │ ├── SeedFactory.php
│ │ ├── SeedRun.php
│ │ └── Status.php
│ ├── Lists
│ │ ├── RoutesCommand.php
│ │ └── ServicesCommand.php
│ ├── Mail
│ │ └── InlinerCommand.php
│ ├── Make
│ │ ├── CollectionCommand.php
│ │ ├── ConsoleCommand.php
│ │ ├── ModelCommand.php
│ │ └── stubs
│ │ │ ├── makeCollection.stub
│ │ │ ├── makeConsole.stub
│ │ │ └── makeModel.stub
│ ├── Queue
│ │ └── Listen.php
│ ├── README.md
│ ├── Script
│ │ └── RunCommand.php
│ ├── Server
│ │ ├── BenchmarkCommand.php
│ │ ├── ClutchCommand.php
│ │ ├── EnvCommand.php
│ │ ├── Optimize
│ │ │ └── config.php
│ │ ├── OptimizeCommand.php
│ │ └── ServeCommand.php
│ ├── Vendor
│ │ ├── NewCommand.php
│ │ ├── PublishCommand.php
│ │ └── stubs
│ │ │ └── ServiceProvider.stub
│ └── composer.json
│ ├── Contracts
│ ├── Flysystem
│ │ └── AdapterInterface.php
│ ├── Mail
│ │ └── MailInterface.php
│ ├── Providers
│ │ └── ModuleInterface.php
│ └── composer.json
│ ├── Exceptions
│ ├── AccessNotAllowedException.php
│ ├── ControllerNotFoundException.php
│ ├── FileNotFoundException.php
│ ├── Handler.php
│ ├── ServiceAliasNotFoundException.php
│ ├── ViewFileNotFoundException.php
│ └── composer.json
│ ├── Facades
│ ├── Auth.php
│ ├── BehatMink.php
│ ├── Cache.php
│ ├── Config.php
│ ├── Crypt.php
│ ├── DB.php
│ ├── Facade.php
│ ├── Filter.php
│ ├── Flash.php
│ ├── Flysystem.php
│ ├── FlysystemManager.php
│ ├── Log.php
│ ├── Queue.php
│ ├── Redirect.php
│ ├── Request.php
│ ├── Response.php
│ ├── Route.php
│ ├── Security.php
│ ├── Session.php
│ ├── Tag.php
│ ├── URL.php
│ ├── Validator.php
│ ├── View.php
│ └── composer.json
│ ├── Kernel
│ ├── Kernel.php
│ ├── KernelTrait.php
│ └── composer.json
│ ├── Lang
│ ├── Lang.php
│ ├── LangFacade.php
│ ├── LangServiceProvider.php
│ └── composer.json
│ ├── Mail
│ ├── Mail.php
│ ├── MailFacade.php
│ ├── MailServiceProvider.php
│ ├── Mailgun
│ │ └── Mailgun.php
│ ├── SwiftMailer
│ │ ├── MailMailer.php
│ │ ├── SendmailMailer.php
│ │ ├── SmtpMailer.php
│ │ └── Swift.php
│ └── composer.json
│ ├── Providers
│ ├── Aliaser.php
│ ├── Annotations.php
│ ├── Application.php
│ ├── Auth.php
│ ├── BehatMink.php
│ ├── Cache.php
│ ├── CollectionManager.php
│ ├── Console.php
│ ├── Cookies.php
│ ├── Crypt.php
│ ├── DB.php
│ ├── Dispatcher.php
│ ├── Escaper.php
│ ├── EventsManager.php
│ ├── Filter.php
│ ├── Flash.php
│ ├── Flysystem.php
│ ├── Log.php
│ ├── ModelManager.php
│ ├── ModelMetadata.php
│ ├── Module.php
│ ├── Mongo.php
│ ├── Queue.php
│ ├── Redirect.php
│ ├── Request.php
│ ├── Response.php
│ ├── Router.php
│ ├── RouterAnnotations.php
│ ├── Security.php
│ ├── ServiceProvider.php
│ ├── Session.php
│ ├── Tag.php
│ ├── TransactionManager.php
│ ├── URL.php
│ ├── Validator.php
│ └── composer.json
│ ├── Services
│ ├── Container.php
│ ├── Mapper.php
│ ├── ServiceMagicMethods.php
│ └── composer.json
│ ├── Support
│ ├── Auth
│ │ └── Auth.php
│ ├── Curl
│ │ ├── README.md
│ │ └── RESTful.php
│ ├── DB
│ │ └── Factory.php
│ ├── Helpers
│ │ ├── facade.php
│ │ ├── init.php
│ │ ├── misc.php
│ │ ├── paths.php
│ │ ├── slayer.php
│ │ └── url.php
│ ├── Phalcon
│ │ ├── Crypt.php
│ │ ├── Di.php
│ │ ├── Events
│ │ │ └── Manager.php
│ │ ├── Http
│ │ │ ├── Middleware.php
│ │ │ └── Request.php
│ │ ├── Mvc
│ │ │ ├── Application.php
│ │ │ ├── Collection.php
│ │ │ ├── Controller.php
│ │ │ ├── Dispatcher.php
│ │ │ ├── Router.php
│ │ │ ├── URL.php
│ │ │ └── View.php
│ │ └── Session
│ │ │ └── Files.php
│ ├── Phinx
│ │ ├── Db
│ │ │ └── Table.php
│ │ ├── Migration
│ │ │ └── AbstractMigration.php
│ │ └── Seed
│ │ │ └── AbstractSeed.php
│ ├── Queue
│ │ ├── Beanstalkd
│ │ │ └── Beanstalkd.php
│ │ ├── DriverInterface.php
│ │ └── Queue.php
│ ├── Redirect
│ │ └── Redirect.php
│ ├── WithMagicMethodTrait.php
│ └── composer.json
│ ├── TestSuite
│ ├── Behat
│ │ └── Mink
│ │ │ ├── Adapters
│ │ │ ├── DriverInterface.php
│ │ │ └── Goutte.php
│ │ │ ├── Mink.php
│ │ │ └── config.php
│ └── composer.json
│ ├── Util
│ ├── Benchmark
│ │ ├── Benchmark.php
│ │ └── BenchmarkServiceProvider.php
│ ├── Composer
│ │ ├── Builder.php
│ │ └── TestConsole.php
│ ├── Validator
│ │ ├── Mapper.php
│ │ ├── Tests
│ │ │ └── Sample.php
│ │ └── Validator.php
│ └── composer.json
│ └── View
│ ├── Blade
│ └── BladeAdapter.php
│ ├── ViewServiceProvider.php
│ ├── Volt
│ └── VoltAdapter.php
│ └── composer.json
└── tests
├── .env.travis
├── clarity
├── Console
│ ├── AppTest.php
│ ├── CLITest.php
│ └── ServerTest.php
├── Providers
│ └── ResolverTest.php
└── Support
│ ├── CurlTest.php
│ ├── HelpersTest.php
│ └── Phalcon
│ ├── HttpTest.php
│ └── MvcTest.php
└── slayer
├── acceptance
└── WelcomeAndLoginAndRegisterTest.php
└── config
└── AppTest.php
/.php_cs:
--------------------------------------------------------------------------------
1 | setRules([
5 | '@PSR2' => true,
6 | // 'strict_param' => true,
7 | 'array_syntax' => ['syntax' => 'short'],
8 | ])
9 | ->setFinder(
10 | PhpCsFixer\Finder::create()
11 | ->in(__DIR__)
12 | );
13 |
--------------------------------------------------------------------------------
/autoload.php:
--------------------------------------------------------------------------------
1 | modules()->run('main');
6 |
--------------------------------------------------------------------------------
/build/ci/beanstalkd.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | (sudo apt-get install -y beanstalkd;sudo service beanstalkd start;beanstalkd -h)
4 | sudo bash -c 'echo "START=yes" >> /etc/default/beanstalkd'
5 | sudo service beanstalkd restart
6 | beanstalkd -v
7 |
8 | sleep 5
9 |
--------------------------------------------------------------------------------
/build/ci/build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # clone slayer
4 | git clone -b ${SLAYER_VERSION} --depth 1 https://github.com/phalconslayer/slayer.git ~/${SLAYER_FOLDER}
5 |
6 | cd ~/${SLAYER_FOLDER}
7 |
8 | rm composer.lock
9 |
10 |
11 | #-------------------------------------------------------------------------------
12 |
13 |
14 | # check php info
15 | php -m
16 |
17 | # check composer updates
18 | composer self-update
19 |
20 | # require framework based on version
21 | composer require phalconslayer/framework:dev-${TRAVIS_BRANCH}
22 | composer require techpivot/phalcon-ci-installer:~1.0
23 |
24 | # install dependencies
25 | composer update
26 |
27 |
28 | #-------------------------------------------------------------------------------
29 |
30 |
31 | # copy .env.travis as .env file
32 | cp vendor/phalconslayer/framework/tests/.env.travis .env
33 | mkdir config/travis
34 | cat .env
35 |
36 |
37 | #-------------------------------------------------------------------------------
38 |
39 |
40 | # execute phalcon ci installer
41 | vendor/bin/install-phalcon.sh ${PHALCON_VERSION}
42 |
43 |
44 | #-------------------------------------------------------------------------------
45 |
46 |
47 | # create 'slayer' database
48 | mysql -e 'create database slayer charset=utf8mb4 collate=utf8mb4_unicode_ci;'
49 |
50 | # db migrations
51 | php brood db:migrate
52 |
53 |
54 | #-------------------------------------------------------------------------------
55 |
56 |
57 | # built-in web
58 | php -S ${SERVE_HOST}:${SERVE_PORT} -t public/ > internal-server.log 2>&1 &
59 | sleep 5
60 |
61 | cd ..
62 |
63 | #-------------------------------------------------------------------------------
64 |
--------------------------------------------------------------------------------
/build/ci/script.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # +--------------------------+
4 | # | Run other brood commands |
5 | # +--------------------------+
6 | php brood list:routes
7 |
8 | # db
9 | php brood seed:factory
10 | php brood db:status
11 | php brood db:rollback
12 | php brood db:create Test
13 | php brood seed:create Test
14 | php brood seed:run
15 | php brood db:rollback
16 |
17 | # app
18 | php brood app:controller Test main
19 | php brood app:module test
20 | php brood app:route Test test
21 |
22 | # clear
23 | php brood clear:cache
24 | php brood clear:compiled
25 | php brood clear:logs
26 | php brood clear:session
27 | php brood clear:views
28 | php brood clear:all
29 |
30 | # mail
31 | php brood mail:inliner
32 |
33 | # make
34 | php brood make:collection Test
35 | php brood make:console Test
36 | php brood make:model Test
37 |
--------------------------------------------------------------------------------
/build/clarity.sh:
--------------------------------------------------------------------------------
1 | git subsplit init git@github.com:phalconslayer/framework.git
2 | git subsplit publish --heads="master 1.3" src/Clarity/Console:git@github.com:ps-clarity/console.git
3 | git subsplit publish --heads="master 1.3" src/Clarity/Contracts:git@github.com:ps-clarity/contracts.git
4 | git subsplit publish --heads="master 1.3" src/Clarity/Exceptions:git@github.com:ps-clarity/exceptions.git
5 | git subsplit publish --heads="master 1.3" src/Clarity/Facades:git@github.com:ps-clarity/facades.git
6 | git subsplit publish --heads="master 1.3" src/Clarity/Kernel:git@github.com:ps-clarity/kernel.git
7 | git subsplit publish --heads="master 1.3" src/Clarity/Lang:git@github.com:ps-clarity/lang.git
8 | git subsplit publish --heads="master 1.3" src/Clarity/Mail:git@github.com:ps-clarity/mail.git
9 | git subsplit publish --heads="master 1.3" src/Clarity/Providers:git@github.com:ps-clarity/providers.git
10 | git subsplit publish --heads="master 1.3" src/Clarity/Services:git@github.com:ps-clarity/services.git
11 | git subsplit publish --heads="master 1.3" src/Clarity/Support:git@github.com:ps-clarity/support.git
12 | git subsplit publish --heads="master 1.3" src/Clarity/Util:git@github.com:ps-clarity/util.git
13 | git subsplit publish --heads="master 1.3" src/Clarity/TestSuite:git@github.com:ps-clarity/test-suite.git
14 | git subsplit publish --heads="master 1.3" src/Clarity/View:git@github.com:ps-clarity/view.git
15 |
16 | rm -rf .subsplit/
--------------------------------------------------------------------------------
/codecept/_bootstrap.php:
--------------------------------------------------------------------------------
1 | modules()->run('main');
9 | }
10 |
--------------------------------------------------------------------------------
/codecept/functional.suite.yml:
--------------------------------------------------------------------------------
1 | # Codeception Test Suite Configuration
2 | #
3 | # Suite for functional (integration) tests
4 | # Emulate web requests and make application process them
5 | # Include one of framework modules (Symfony2, Yii2, Laravel5) to use it
6 |
7 | class_name: FunctionalTester
8 | modules:
9 | enabled:
10 | # add framework module here
11 | - \Helper\Functional
--------------------------------------------------------------------------------
/codecept/functional/_bootstrap.php:
--------------------------------------------------------------------------------
1 | modules()->run('main');
9 | }
10 |
--------------------------------------------------------------------------------
/codecept/unit.suite.yml:
--------------------------------------------------------------------------------
1 | # Codeception Test Suite Configuration
2 | #
3 | # Suite for unit (internal) tests.
4 |
5 | class_name: UnitTester
6 | modules:
7 | enabled:
8 | - Asserts
9 | - \Helper\Unit
--------------------------------------------------------------------------------
/codecept/unit/MailTest.php:
--------------------------------------------------------------------------------
1 | env('MAILER_HOST'),
33 | 'port' => env('MAILER_PORT'),
34 | 'username' => env('MAILER_USERNAME'),
35 | 'password' => env('MAILER_PASSWORD'),
36 | 'encryption' => env('MAILER_ENCRYPTION', 'tls'),
37 | 'from' => env('MAILER_MAIL_FROM'),
38 | ];
39 |
40 | $adapters = [
41 | // SendmailMailer::class => $default,
42 | // MailMailer::class => $default,
43 | // SmtpMailer::class => $default,
44 | // Mailgun::class => ['from' => env('MAILER_MAIL_FROM')],
45 | ];
46 |
47 | foreach ($adapters as $class => $options) {
48 | $adapter = $this->getMailInstance($class, $options);
49 |
50 | $adapter->send('welcome', [], function ($mail) {
51 | $mail->subject('Codeception Test');
52 | $mail->from('daison12006013@gmail.com');
53 | $mail->to(['daison12006013@gmail.com']);
54 | });
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/codecept/unit/ValidatorTest.php:
--------------------------------------------------------------------------------
1 | make(
29 | $sample->validationData(),
30 | $sample->rules()
31 | );
32 |
33 | if ($validation->fails()) {
34 | dd($validation->errors());
35 | }
36 |
37 | # there should be no error at all...
38 | $this->assertFalse($validation->fails());
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/codecept/unit/_bootstrap.php:
--------------------------------------------------------------------------------
1 | modules()->run('main');
9 | }
10 |
--------------------------------------------------------------------------------
/codecept/unit/resources/lang/en/folder/site.php:
--------------------------------------------------------------------------------
1 | 'Welcome Human to S.layer',
5 | 'motd_with_params' => 'Welcome {name} to {project}',
6 | 'motd_with_params_2' => 'Welcome :name to :project',
7 |
8 | 'array' => [
9 | 'motd' => 'Welcome Human to S.layer',
10 | 'motd_with_params' => 'Welcome {name} to {project}',
11 | 'motd_with_params_2' => 'Welcome :name to :project',
12 | ],
13 | ];
14 |
--------------------------------------------------------------------------------
/codecept/unit/resources/lang/en/simple.php:
--------------------------------------------------------------------------------
1 | 'Welcome Human to S.layer',
5 | 'motd_with_params' => 'Welcome {name} to {project}',
6 | 'motd_with_params_2' => 'Welcome :name to :project',
7 |
8 | 'array' => [
9 | 'motd' => 'Welcome Human to S.layer',
10 | 'motd_with_params' => 'Welcome {name} to {project}',
11 | 'motd_with_params_2' => 'Welcome :name to :project',
12 | ],
13 | ];
14 |
--------------------------------------------------------------------------------
/codeception.yml:
--------------------------------------------------------------------------------
1 | actor: Tester
2 | paths:
3 | tests: codecept
4 | log: codecept/_output
5 | data: codecept/_data
6 | support: codecept/_support
7 | envs: codecept/_envs
8 | settings:
9 | bootstrap: _bootstrap.php
10 | colors: true
11 | memory_limit: 1024M
12 | extensions:
13 | enabled:
14 | - Codeception\Extension\RunFailed
15 | modules:
16 | config:
17 | Db:
18 | dsn: ''
19 | user: ''
20 | password: ''
21 | dump: tests/_data/dump.sql
22 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "phalconslayer/framework",
3 | "keywords": [
4 | "skeleton",
5 | "boilerplate",
6 | "framework",
7 | "phalcon",
8 | "slayer",
9 | "bootstrap"
10 | ],
11 | "description": "The foundation of Phalcon Slayer",
12 | "license": "MIT",
13 | "homepage": "http://github.com/phalconslayer/framework",
14 | "support": {
15 | "issues": "https://github.com/phalconslayer/framework/issues",
16 | "source": "https://github.com/phalconslayer/framework"
17 | },
18 | "authors": [
19 | {
20 | "name": "Daison Carino",
21 | "email": "daison12006013@gmail.com"
22 | }
23 | ],
24 | "require": {
25 | "classpreloader/classpreloader": "^3.0",
26 | "classpreloader/console": "^2.0",
27 | "composer/composer": "^1.0",
28 | "fzaninotto/faker": "~1.4",
29 | "guzzlehttp/guzzle": "6.1.*",
30 | "illuminate/support": "5.4.*",
31 | "jenssegers/blade": "^1.0",
32 | "paragonie/random_compat": "~1.4|~2.0",
33 | "league/flysystem": "^1.0",
34 | "league/tactician": "^0.6",
35 | "mailgun/mailgun-php": "~1.7|~2.2",
36 | "monolog/monolog": "^1.15",
37 | "robmorgan/phinx": "0.5.*",
38 | "swiftmailer/swiftmailer": "^5.4",
39 | "symfony/console": "^2.7",
40 | "symfony/debug": "~3.2",
41 | "symfony/process": "^2.7",
42 | "symfony/var-dumper": "^2.7",
43 | "tijsverkoyen/css-to-inline-styles": "^1.5",
44 | "vlucas/phpdotenv": "^2.0",
45 | "psy/psysh": "0.7.*",
46 | "php-http/guzzle6-adapter": "1.1.*",
47 | "respect/validation": "^1.1"
48 | },
49 | "replace": {
50 | "clarity/console": "self.version",
51 | "clarity/contracts": "self.version",
52 | "clarity/exceptions": "self.version",
53 | "clarity/facades": "self.version",
54 | "clarity/kernel": "self.version",
55 | "clarity/lang": "self.version",
56 | "clarity/mail": "self.version",
57 | "clarity/providers": "self.version",
58 | "clarity/services": "self.version",
59 | "clarity/support": "self.version",
60 | "clarity/test-suite": "self.version",
61 | "clarity/util": "self.version",
62 | "clarity/view": "self.version"
63 | },
64 | "require-dev": {
65 | "behat/mink": "^1.7",
66 | "behat/mink-goutte-driver": "^1.2",
67 | "phpunit/phpunit": "^4.8",
68 | "mockery/mockery": "^0.9",
69 | "fzaninotto/faker": "^1.4"
70 | },
71 | "autoload": {
72 | "psr-4": {
73 | "Clarity\\": "src/Clarity/"
74 | },
75 | "files": [
76 | "src/Clarity/Support/Helpers/init.php"
77 | ]
78 | },
79 | "extra": {
80 | "branch-alias": {
81 | "dev-master": "1.5-dev"
82 | }
83 | },
84 | "minimum-stability": "dev"
85 | }
86 |
--------------------------------------------------------------------------------
/contributing.md:
--------------------------------------------------------------------------------
1 | # Contribution Guide
2 |
3 | We priorities your concerns, you could also contribute to us, you may
4 | - [create an issue](https://github.com/phalconslayer/framework/issues/new)
5 | - [discuss some new features](https://phalconslayer.readme.io/discuss-new)
6 | - [do pull request or merge request](https://github.com/phalconslayer/framework/pulls)
7 |
8 | Automated testing is just our first way to automate every area of our code. Everytime we add/change a code, their might be possibilities that affects other relying code.
9 |
10 | To hardly test everything, we must help each other, building an app would really help you to tackle those bugs, discrepancies or anything related.
11 |
12 | Try to read our Coding Style if you will be pushing some codes. [Click Here](https://phalconslayer.readme.io/docs/misc-coding-style)
13 |
14 | # Versioning and Releasing Process
15 |
16 | We follow [semver.org](http://semver.org), there is major.minor.patch
17 |
18 | Each release we have a branch that follows until the **minor** something like ``1.2`` branch
19 |
20 | ### patch
21 |
22 | The **patch** should be interpreted as a ***bug fix*** only for each branch. There will be no new/removed features or added/removed files.
23 |
24 | This patch only affects this repository itself, while the [framework](https://github.com/phalconslayer/framework) has a different approach, we can remove a scope code but the behavior must still retain. We only deprecate functions/methods or classes but we must not remove them until the **minor** release.
25 |
26 | Inshort: we must checkout to branch ``1.2`` to create a fix release.
27 |
28 | If a fixed merged to branch ``1.2`` the owner must release a new patch version.
29 | Scenario, if the previous version was ``1.2.0`` the owner must release ``1.2.1`` pointing to branch ``1.2``
30 |
31 | ### minor
32 |
33 | The **minor** should be able to add/remove features.
34 | Scenario, if the previous version was ``1.2.8`` tag, the owner must create a new branch ``1.3`` and should release ``1.3.0`` pointing to branch ``1.3``
35 |
36 | Inshort: we must checkout to branch ``master`` as it aliases the **framework** master branch as ``1.3-dev`` to be able to add/remove new features.
37 |
38 | ### major
39 |
40 | The **major** release will affect all the relying trees such as **documentations**, **framework** repo, **configurations**, **folder structure**.
41 |
--------------------------------------------------------------------------------
/php-cs-fixer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solid-layer/framework/59f39fac2094598918731b107ba0b9298bab6394/php-cs-fixer
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
16 | ./tests
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # S.Layer's Kernel
2 |
3 | ---
4 |
5 | You can post issues here, submit a pull request, discuss things you can imagine!
6 |
7 | ##### Phalcon Rank
8 | [](https://phalconist.com/phalconslayer/slayer)
9 |
10 | ##### Code Standard
11 | [](https://insight.sensiolabs.com/projects/5d5e8a5c-62e6-43cf-9d36-39f62cefdcd2)
12 |
13 | ##### master (alias v1.5) Status:
14 | [](https://travis-ci.org/phalconslayer/framework)
15 |
16 | ##### v1.4 Status:
17 | [](https://travis-ci.org/phalconslayer/framework)
18 |
19 | ---
20 |
21 | 
22 |
23 | Slayer is made to support dependencies while still reaching the speed of Phalcon Framework, it is built with extensive packages such as flysystem, symfony components, swiftmailer, phinx and many more (refer to `composer.json`)
24 |
25 | ## Contributing
26 |
27 | Please read the [CONTRIBUTING.md](https://github.com/phalconslayer/framework/blob/master/contributing.md)
28 |
29 | You can pull the most updated branch `master`, create a pull request of your forked branch updates, issues should be reported using GitHub's Issues and all security concerns should be emailed to `daison12006013@gmail.com` promptly.
30 |
31 | Thanks to all [contributors](https://github.com/phalconslayer/framework/graphs/contributors).
32 |
33 | ## License
34 |
35 | Slayer is an open-source and licensed under [MIT License](http://opensource.org/licenses/MIT).
36 |
--------------------------------------------------------------------------------
/src/Clarity/Console/App/stubs/controller/controller.stub:
--------------------------------------------------------------------------------
1 | isPost()) {
19 | // do some stuff ...
20 | }
21 | }
22 |
23 | /**
24 | * To show an output based on the requested ID
25 | *
26 | * @param $id
27 | *
28 | * @return mixed
29 | */
30 | public function show($id)
31 | {
32 | return view('{path.to.resources.view}.show')
33 | ->with('id', $id)
34 | ->batch([
35 | 'var1' => true,
36 | 'var2' => 'this is another value for $var2',
37 | ]);
38 | }
39 |
40 | /**
41 | * To update a record based on the requested ID
42 | *
43 | * @param $id
44 | *
45 | * @return void
46 | */
47 | public function update($id)
48 | {
49 | # process the post request
50 | if (request()->isPost()) {
51 | // ...
52 | }
53 | }
54 |
55 | /**
56 | * To delete a record
57 | *
58 | * @param $id The id to be deleted
59 | *
60 | * @return void
61 | */
62 | public function delete($id)
63 | {
64 | # process the request which it must be post and ajax request
65 | if (request()->isPost() && request()->isAjax()) {
66 | // ...
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/Clarity/Console/App/stubs/module/base_controller.stub:
--------------------------------------------------------------------------------
1 | get('dispatcher')
36 | ->setDefaultNamespace('App\{module}\Controllers');
37 | }
38 |
39 | /**
40 | * {@inherit}
41 | */
42 | public function afterModuleRun()
43 | {
44 | require_once realpath(__DIR__.'/../').'/Routes.php';
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Clarity/Console/App/stubs/module/index.stub:
--------------------------------------------------------------------------------
1 | modules()
12 | ->run({module})
13 | ->render();
14 |
--------------------------------------------------------------------------------
/src/Clarity/Console/App/stubs/route/functions.stub:
--------------------------------------------------------------------------------
1 | public function initialize()
2 | {
3 | $this->setPaths([
4 | 'namespace' => '{controllerNamespace}',
5 | 'controller' => '{routeName}',
6 | ]);
7 |
8 | $this->setPrefix('/{prefixRouteName}');
9 |
10 | # url as {prefixRouteName}/index
11 | $this->addGet('/index', [
12 | 'action' => 'index'
13 | ]);
14 |
15 | # url as {prefixRouteName}/store
16 | $this->addPost('/store', [
17 | 'action' => 'store'
18 | ]);
19 |
20 | # url as {prefixRouteName}/1/show
21 | $this->addGet('/{id}/show', [
22 | 'action' => 'show'
23 | ]);
24 |
25 | # url as {prefixRouteName}/1/update
26 | $this->addPost('/{id}/update', [
27 | 'action' => 'update'
28 | ]);
29 |
30 | # url as {prefixRouteName}/1/delete
31 | $this->addPost('/{id}/delete', [
32 | 'action' => 'delete'
33 | ]);
34 | }
35 |
--------------------------------------------------------------------------------
/src/Clarity/Console/App/stubs/route/route.stub:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Clear;
12 |
13 | use Clarity\Console\CLI;
14 | use Clarity\Console\Brood;
15 |
16 | /**
17 | * A console command that calls all the clear commands.
18 | */
19 | class AllCommand extends Brood
20 | {
21 | use ClearTrait;
22 |
23 | /**
24 | * {@inheritdoc}
25 | */
26 | protected $name = 'clear:all';
27 |
28 | /**
29 | * {@inheritdoc}
30 | */
31 | protected $description = 'Clear all listed';
32 |
33 | /**
34 | * {@inheritdoc}
35 | */
36 | public function slash()
37 | {
38 | CLI::bash([
39 | 'php brood clear:cache',
40 | 'php brood clear:compiled',
41 | 'php brood clear:logs',
42 | 'php brood clear:session',
43 | 'php brood clear:views',
44 | ]);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Clear/CacheCommand.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Clear;
12 |
13 | use Clarity\Console\Brood;
14 |
15 | /**
16 | * A console command that clears the storage cache.
17 | */
18 | class CacheCommand extends Brood
19 | {
20 | use ClearTrait;
21 |
22 | /**
23 | * {@inheritdoc}
24 | */
25 | protected $name = 'clear:cache';
26 |
27 | /**
28 | * {@inheritdoc}
29 | */
30 | protected $description = 'Clear the storage/cache folder';
31 |
32 | /**
33 | * {@inheritdoc}
34 | */
35 | public function slash()
36 | {
37 | $this->clear(storage_path('cache'));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Clear/ClearTrait.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Clear;
12 |
13 | /**
14 | * A console command that clears the storage cache.
15 | */
16 | trait ClearTrait
17 | {
18 | /**
19 | * Lists of ignored files.
20 | *
21 | * @var mixed
22 | */
23 | private $ignored_files = [
24 | '.gitignore',
25 | ];
26 |
27 | /**
28 | * This recursively clears all files including folders, based on the $path
29 | * provided.
30 | *
31 | * @param string $path The designated path to be cleared
32 | * @return void
33 | */
34 | public function clear($path)
35 | {
36 | $files = new \RecursiveIteratorIterator(
37 | new \RecursiveDirectoryIterator(
38 | $path,
39 | \RecursiveDirectoryIterator::SKIP_DOTS
40 | ),
41 | \RecursiveIteratorIterator::CHILD_FIRST
42 | );
43 |
44 | foreach ($files as $file) {
45 | if (in_array($file->getFileName(), $this->ignored_files)) {
46 | continue;
47 | }
48 |
49 | if ($file->isDir()) {
50 | rmdir($file->getRealPath());
51 | } else {
52 | unlink($file->getRealPath());
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Clear/CompiledCommand.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Clear;
12 |
13 | use Clarity\Console\Brood;
14 |
15 | /**
16 | * A console command that clears compiled.php file.
17 | */
18 | class CompiledCommand extends Brood
19 | {
20 | use ClearTrait;
21 |
22 | /**
23 | * {@inheritdoc}
24 | */
25 | protected $name = 'clear:compiled';
26 |
27 | /**
28 | * {@inheritdoc}
29 | */
30 | protected $description = 'Clear the compiled classes';
31 |
32 | /**
33 | * {@inheritdoc}
34 | */
35 | public function slash()
36 | {
37 | $this->clear(
38 | url_trimmer(storage_path('slayer'))
39 | );
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Clear/LogsCommand.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Clear;
12 |
13 | use Clarity\Console\Brood;
14 |
15 | /**
16 | * A console command that clears the storage logs.
17 | */
18 | class LogsCommand extends Brood
19 | {
20 | use ClearTrait;
21 |
22 | /**
23 | * {@inheritdoc}
24 | */
25 | protected $name = 'clear:logs';
26 |
27 | /**
28 | * {@inheritdoc}
29 | */
30 | protected $description = 'Clear the storage/logs folder';
31 |
32 | /**
33 | * {@inheritdoc}
34 | */
35 | public function slash()
36 | {
37 | $this->clear(storage_path('logs'));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Clear/SessionCommand.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Clear;
12 |
13 | use Clarity\Console\Brood;
14 |
15 | /**
16 | * A console command that clears the session storage.
17 | */
18 | class SessionCommand extends Brood
19 | {
20 | use ClearTrait;
21 |
22 | /**
23 | * {@inheritdoc}
24 | */
25 | protected $name = 'clear:session';
26 |
27 | /**
28 | * {@inheritdoc}
29 | */
30 | protected $description = 'Clear the storage/session folder';
31 |
32 | /**
33 | * {@inheritdoc}
34 | */
35 | public function slash()
36 | {
37 | $this->clear(storage_path('session'));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Clear/ViewsCommand.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Clear;
12 |
13 | use Clarity\Console\Brood;
14 |
15 | /**
16 | * A console command that clears the cache'd views.
17 | */
18 | class ViewsCommand extends Brood
19 | {
20 | use ClearTrait;
21 |
22 | /**
23 | * {@inheritdoc}
24 | */
25 | protected $name = 'clear:views';
26 |
27 | /**
28 | * {@inheritdoc}
29 | */
30 | protected $description = 'Clear the storage/views folder';
31 |
32 | /**
33 | * {@inheritdoc}
34 | */
35 | public function slash()
36 | {
37 | $this->clear(
38 | url_trimmer(storage_path('views'))
39 | );
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Clarity/Console/DB/Create.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\DB;
12 |
13 | use Phinx\Util\Util;
14 | use Symfony\Component\Console\Input\InputArgument;
15 |
16 | /**
17 | * Create a db migration.
18 | */
19 | class Create extends AbstractCommand
20 | {
21 | /**
22 | * {@inheritdoc}
23 | */
24 | protected $name = 'db:create';
25 |
26 | /**
27 | * {@inheritdoc}
28 | */
29 | protected $description = 'Create a new migration';
30 |
31 | /**
32 | * {@inheritdoc}
33 | */
34 | public function slash()
35 | {
36 | $path = realpath($this->getDefaultConfig()->getMigrationPath());
37 |
38 | if (! file_exists($path)) {
39 | if ($this->confirm('Create migrations directory? [y]/n ', true)) {
40 | mkdir($path, 0755, true);
41 | }
42 | }
43 |
44 | $this->verifyMigrationDirectory($path);
45 |
46 | $class_name = $this->getInput()->getArgument('name');
47 |
48 | $this->checkValidPhinxClassName($class_name);
49 |
50 | $this->checkUniqueMigrationClassName($class_name, $path);
51 |
52 | $file_name = $this->mapClassNameToFileName($class_name);
53 | $file_path = $path.'/'.$file_name;
54 |
55 | $contents = file_get_contents($this->getMigrationTemplateFilename());
56 |
57 | $contents = strtr($contents, [
58 | '$useClassName' => $this->getMigrationBaseClassName(false),
59 | '$className' => $class_name,
60 | '$version' => Util::getVersionFromFileName($file_name),
61 | '$baseClassName' => $this->getMigrationBaseClassName(true),
62 | ]);
63 |
64 | if (false === file_put_contents($file_path, $contents)) {
65 | throw new \RuntimeException(sprintf(
66 | 'File "%s" could not be written',
67 | $file_path
68 | ));
69 | }
70 |
71 | $this->getOutput()->writeln('created '.str_replace(getcwd(), '', $file_path));
72 | }
73 |
74 | /**
75 | * {@inheritdoc}
76 | */
77 | public function arguments()
78 | {
79 | return [
80 | ['name', InputArgument::REQUIRED, 'What is the name of the migration?'],
81 | ];
82 | }
83 |
84 | /**
85 | * {@inheritdoc}
86 | */
87 | protected function getMigrationTemplateFilename()
88 | {
89 | $file = url_trimmer(config()->path->storage.'/stubs/db/MigrationCreate.stub');
90 |
91 | if (! file_exists($file)) {
92 | throw new \RuntimeException("Migration Template [$file] not found.");
93 | }
94 |
95 | return $file;
96 | }
97 |
98 | /**
99 | * {@inheritdoc}
100 | */
101 | protected function mapClassNameToFileName($class_name)
102 | {
103 | return Util::mapClassNameToFileName($class_name);
104 | }
105 |
106 | /**
107 | * {@inheritdoc}
108 | */
109 | protected function getMigrationBaseClassName($drop_namespace = fakse)
110 | {
111 | $class_name = \Clarity\Support\Phinx\Migration\AbstractMigration::class;
112 |
113 | return $drop_namespace ? substr(strrchr($class_name, '\\'), 1) : $class_name;
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/src/Clarity/Console/DB/SeedCreate.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\DB;
12 |
13 | use Symfony\Component\Console\Input\InputArgument;
14 |
15 | /**
16 | * Create a database seeder.
17 | */
18 | class SeedCreate extends AbstractCommand
19 | {
20 | /**
21 | * {@inheritdoc}
22 | */
23 | protected $name = 'seed:create';
24 |
25 | /**
26 | * {@inheritdoc}
27 | */
28 | protected $description = 'Create a new database seeder';
29 |
30 | /**
31 | * {@inheritdoc}
32 | */
33 | protected $help = "\nCreates a new database seeder\n";
34 |
35 | /**
36 | * {@inheritdoc}
37 | */
38 | public function slash()
39 | {
40 | # get the seed path from the config
41 | $path = realpath($this->getDefaultConfig()->getSeedPath());
42 |
43 | if (! file_exists($path)) {
44 | if ($this->confirm('Create migrations directory? [y]/n ', true)) {
45 | mkdir($path, 0755, true);
46 | }
47 | }
48 |
49 | $this->verifySeedDirectory($path);
50 |
51 | $class_name = $this->getInput()->getArgument('name');
52 |
53 | $this->checkValidPhinxClassName($class_name);
54 |
55 | // Compute the file path
56 | $file_path = $path.'/'.$class_name.'.php';
57 |
58 | if (is_file($file_path)) {
59 | throw new \InvalidArgumentException(sprintf(
60 | 'The file "%s" already exists',
61 | basename($file_path)
62 | ));
63 | }
64 |
65 | # inject the class names appropriate to this seeder
66 | $contents = file_get_contents($this->getSeedTemplateFilename());
67 |
68 | $classes = [
69 | '$useClassName' => 'Clarity\Support\Phinx\Seed\AbstractSeed',
70 | '$className' => $class_name,
71 | '$baseClassName' => 'AbstractSeed',
72 | ];
73 |
74 | $contents = strtr($contents, $classes);
75 |
76 | if (false === file_put_contents($file_path, $contents)) {
77 | throw new \RuntimeException(sprintf(
78 | 'The file "%s" could not be written to',
79 | $path
80 | ));
81 | }
82 |
83 | $this->getOutput()->writeln('using seed base class '.$classes['$useClassName']);
84 | $this->getOutput()->writeln('created .'.str_replace(getcwd(), '', $file_path));
85 | }
86 |
87 | /**
88 | * {@inheritdoc}
89 | */
90 | public function arguments()
91 | {
92 | return [
93 | ['name', InputArgument::REQUIRED, 'What is the name of the seeder?'],
94 | ];
95 | }
96 |
97 | /**
98 | * {@inheritdoc}
99 | */
100 | protected function getSeedTemplateFilename()
101 | {
102 | $file = url_trimmer(config()->path->storage.'/stubs/db/SeedCreate.stub');
103 |
104 | if (! file_exists($file)) {
105 | throw new \RuntimeException("Seed Template [$file] not found.");
106 | }
107 |
108 | return $file;
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/src/Clarity/Console/DB/SeedFactory.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\DB;
12 |
13 | use Clarity\Support\DB\Factory;
14 | use Clarity\Console\Brood;
15 |
16 | /**
17 | * A console command that fills/seeds the database.
18 | */
19 | class SeedFactory extends Brood
20 | {
21 | /**
22 | * {@inheritdoc}
23 | */
24 | protected $name = 'seed:factory';
25 |
26 | /**
27 | * {@inheritdoc}
28 | */
29 | protected $description = 'Seed based on the factories';
30 |
31 | /**
32 | * {@inheritdoc}
33 | */
34 | public function slash()
35 | {
36 | $factory = new Factory($this);
37 | $files = folder_files(config()->path->database.'factories');
38 |
39 | if (! empty($files)) {
40 | foreach ($files as $file) {
41 | $this->comment('Processing '.basename($file).'...');
42 |
43 | require $file;
44 |
45 | $this->info('Done.'."\n");
46 | }
47 | }
48 |
49 | return $this;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/Clarity/Console/DB/Status.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\DB;
12 |
13 | use Symfony\Component\Console\Input\InputOption;
14 |
15 | /**
16 | * Check the database status.
17 | */
18 | class Status extends AbstractCommand
19 | {
20 | /**
21 | * {@inheritdoc}
22 | */
23 | protected $name = 'db:status';
24 |
25 | /**
26 | * {@inheritdoc}
27 | */
28 | protected $description = 'Show migration status';
29 |
30 | /**
31 | * {@inheritdoc}
32 | */
33 | protected $help = <<status command prints a list of all migrations, along with their current status
35 |
36 | php brood db:status
37 | php brood db:status --format="json";
38 | php brood db:status --env="staging";
39 | EOT;
40 |
41 | /**
42 | * {@inheritdoc}
43 | */
44 | public function slash()
45 | {
46 | $environment = $this->getInput()->getOption('env');
47 | $format = $this->getInput()->getOption('format');
48 |
49 | if (null === $environment) {
50 | $environment = config()->environment;
51 | $this->getOutput()->writeln('warning no environment specified, defaulting to: '.$environment);
52 | } else {
53 | $this->getOutput()->writeln('using environment '.$environment);
54 | }
55 |
56 | if (null !== $format) {
57 | $this->getOutput()->writeln('using format '.$format);
58 | }
59 |
60 | $this->loadManager();
61 |
62 | return $this->getManager()->printStatus($environment, $format);
63 | }
64 |
65 | /**
66 | * {@inheritdoc}
67 | */
68 | public function options()
69 | {
70 | return [
71 | ['--format', null, InputOption::VALUE_REQUIRED, 'The output format: text or json. Defaults to text.'],
72 | ];
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Lists/RoutesCommand.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Lists;
12 |
13 | use Clarity\Console\Brood;
14 | use Clarity\Facades\Route;
15 |
16 | /**
17 | * A console command to show lists of registered routes.
18 | */
19 | class RoutesCommand extends Brood
20 | {
21 | /**
22 | * {@inheritdoc}
23 | */
24 | protected $name = 'list:routes';
25 |
26 | /**
27 | * {@inheritdoc}
28 | */
29 | protected $description = 'Get registered routes';
30 |
31 | /**
32 | * Format the route.
33 | *
34 | * @return array
35 | */
36 | protected function formattedRoute($route)
37 | {
38 | $paths = $route->getPaths();
39 |
40 | return [
41 | 'method' => $route->getHttpMethods() ?: '*any*',
42 | 'path' => $route->getPattern(),
43 | 'controller' => $paths['controller'],
44 | 'action' => $paths['action'],
45 | 'assigned_name' => $route->getName(),
46 | ];
47 | }
48 |
49 | /**
50 | * Dig in the routes provided in the modules.
51 | *
52 | * @return array
53 | */
54 | protected function extractRoutes($routes)
55 | {
56 | $tmp = [];
57 | $counter = 1;
58 |
59 | foreach ($routes as $route) {
60 | $tmp[] = $this->formattedRoute($route);
61 |
62 | if (count($routes) !== $counter++) {
63 | $tmp[] = null;
64 | }
65 | }
66 |
67 | return $tmp;
68 | }
69 |
70 | /**
71 | * {@inheritdoc}
72 | */
73 | public function slash()
74 | {
75 | foreach (di()->getServices() as $service) {
76 | if (! method_exists($def = $service->getDefinition(), 'afterModuleRun')) {
77 | continue;
78 | }
79 |
80 | $def->afterModuleRun();
81 | }
82 |
83 | $table = $this->table(
84 | ['Method', 'Path', 'Controller', 'Action', 'Assigned Name'],
85 | $this->extractRoutes(Route::getRoutes())
86 | );
87 |
88 | $table->render();
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Lists/ServicesCommand.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Lists;
12 |
13 | use Clarity\Console\Brood;
14 |
15 | /**
16 | * Get lists of registered services.
17 | */
18 | class ServicesCommand extends Brood
19 | {
20 | /**
21 | * {@inheritdoc}
22 | */
23 | protected $name = 'list:services';
24 |
25 | /**
26 | * {@inheritdoc}
27 | */
28 | protected $description = 'Get registered services';
29 |
30 | /**
31 | * Format the service.
32 | *
33 | * @return array
34 | */
35 | protected function formattedService($route)
36 | {
37 | $paths = $route->getPaths();
38 |
39 | return [
40 | 'method' => $route->getHttpMethods() ?: '*any*',
41 | 'path' => $route->getPattern(),
42 | 'controller' => $paths['controller'],
43 | 'action' => $paths['action'],
44 | 'assigned_name' => $route->getName(),
45 | ];
46 | }
47 |
48 | /**
49 | * {@inheritdoc}
50 | */
51 | public function slash()
52 | {
53 | $services = [];
54 |
55 | foreach (di()->getServices() as $idx => $service) {
56 | $services[$idx]['name'] = $service->getName();
57 | $services[$idx]['shared'] = $service->isShared() ? 'Yes' : 'No';
58 | $services[$idx]['class'] = null;
59 |
60 | if ($service->isResolved()) {
61 | $services[$idx]['class'] = get_class($service->getDefinition());
62 | } elseif ($service->resolve()) {
63 | $services[$idx]['class'] = get_class($service->resolve());
64 | }
65 | }
66 |
67 | sort($services);
68 |
69 | $table = $this->table(
70 | ['Name', 'Shared', 'Class'],
71 | $services
72 | );
73 |
74 | $table->render();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Make/CollectionCommand.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Make;
12 |
13 | use Clarity\Console\Brood;
14 | use Symfony\Component\Console\Input\InputOption;
15 | use Symfony\Component\Console\Input\InputArgument;
16 |
17 | /**
18 | * A console command that generates a collection template.
19 | */
20 | class CollectionCommand extends Brood
21 | {
22 | /**
23 | * {@inheritdoc}
24 | */
25 | protected $name = 'make:collection';
26 |
27 | /**
28 | * {@inheritdoc}
29 | */
30 | protected $description = 'Create a new collection';
31 |
32 | /**
33 | * {@inheritdoc}
34 | */
35 | public function slash()
36 | {
37 | $arg_name = ucfirst($this->input->getArgument('collection'));
38 |
39 | $stub = file_get_contents(__DIR__.'/stubs/makeCollection.stub');
40 | $stub = str_replace('{collectionName}', $arg_name, $stub);
41 |
42 | $source_name = $this->input->getOption('source');
43 | if (strlen($source_name) == 0) {
44 | $source_name = strtolower($arg_name);
45 | }
46 |
47 | $stub = str_replace('{sourceName}', $source_name, $stub);
48 |
49 | $file_name = $arg_name.'.php';
50 | chdir(config()->path->collections);
51 | $this->comment('Crafting Collection...');
52 |
53 | if (file_exists($file_name)) {
54 | $this->error(' Collection already exists!');
55 | } else {
56 | file_put_contents($file_name, $stub);
57 |
58 | $this->info(' Collection has been created!');
59 | }
60 | }
61 |
62 | /**
63 | * {@inheritdoc}
64 | */
65 | protected function arguments()
66 | {
67 | return [
68 | [
69 | 'collection',
70 | InputArgument::REQUIRED,
71 | 'Model name to be use e.g(Robot)',
72 | ],
73 | ];
74 | }
75 |
76 | /**
77 | * {@inheritdoc}
78 | */
79 | protected function options()
80 | {
81 | return [
82 | [
83 | 'source',
84 | null,
85 | InputOption::VALUE_OPTIONAL,
86 | 'The source name to use',
87 | false,
88 | ],
89 | ];
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Make/ConsoleCommand.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Make;
12 |
13 | use Clarity\Console\Brood;
14 | use Symfony\Component\Console\Input\InputArgument;
15 |
16 | /**
17 | * A console command that generates a brood console template.
18 | */
19 | class ConsoleCommand extends Brood
20 | {
21 | /**
22 | * {@inheritdoc}
23 | */
24 | protected $name = 'make:console';
25 |
26 | /**
27 | * {@inheritdoc}
28 | */
29 | protected $description = 'Generate a new console';
30 |
31 | /**
32 | * {@inheritdoc}
33 | */
34 | public function slash()
35 | {
36 | $arg_name = ucfirst($this->input->getArgument('name'));
37 |
38 | $stub = file_get_contents(__DIR__.'/stubs/makeConsole.stub');
39 | $stub = stubify(
40 | $stub, [
41 | 'consoleName' => $arg_name,
42 | ]
43 | );
44 |
45 | $file_name = $arg_name.'.php';
46 | chdir(config()->path->console);
47 | $this->comment('Crafting Console...');
48 |
49 | if (file_exists($file_name)) {
50 | $this->error(' Console already exists!');
51 | } else {
52 | file_put_contents($file_name, $stub);
53 | $this->info(' Console has been created!');
54 | }
55 | }
56 |
57 | /**
58 | * {@inheritdoc}
59 | */
60 | protected function arguments()
61 | {
62 | return [
63 | ['name', InputArgument::REQUIRED, 'Console name to be used'],
64 | ];
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Make/ModelCommand.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Make;
12 |
13 | use Clarity\Console\Brood;
14 | use Symfony\Component\Console\Input\InputOption;
15 | use Symfony\Component\Console\Input\InputArgument;
16 |
17 | /**
18 | * A console command that generates a model template.
19 | */
20 | class ModelCommand extends Brood
21 | {
22 | /**
23 | * {@inheritdoc}
24 | */
25 | protected $name = 'make:model';
26 |
27 | /**
28 | * {@inheritdoc}
29 | */
30 | protected $description = 'Generate a database model';
31 |
32 | /**
33 | * {@inheritdoc}
34 | */
35 | public function slash()
36 | {
37 | $arg_name = ucfirst($this->input->getArgument('model'));
38 |
39 | $stub = file_get_contents(__DIR__.'/stubs/makeModel.stub');
40 | $stub = str_replace('{modelName}', $arg_name, $stub);
41 |
42 | $source_name = $this->input->getOption('table');
43 | if (strlen($source_name) == 0) {
44 | $source_name = strtolower($arg_name);
45 | }
46 |
47 | $stub = str_replace('{table}', $source_name, $stub);
48 |
49 | $file_name = $arg_name.'.php';
50 | chdir(config()->path->models);
51 | $this->comment('Crafting Model...');
52 |
53 | if (file_exists($file_name)) {
54 | $this->error(' Model already exists!');
55 | } else {
56 | file_put_contents($file_name, $stub);
57 |
58 | $this->info(' Model has been created!');
59 | }
60 | }
61 |
62 | /**
63 | * {@inheritdoc}
64 | */
65 | protected function arguments()
66 | {
67 | return [
68 | [
69 | 'model',
70 | InputArgument::REQUIRED,
71 | 'Model name to be use e.g(User)',
72 | ],
73 | ];
74 | }
75 |
76 | /**
77 | * {@inheritdoc}
78 | */
79 | protected function options()
80 | {
81 | return [
82 | [
83 | 'table',
84 | null,
85 | InputOption::VALUE_OPTIONAL,
86 | 'The table to use',
87 | false,
88 | ],
89 | ];
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Make/stubs/makeCollection.stub:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Queue;
12 |
13 | use Exception;
14 | use Clarity\Facades\Queue;
15 | use Clarity\Console\Brood;
16 |
17 | /**
18 | * Listen to a queue.
19 | */
20 | class Listen extends Brood
21 | {
22 | /**
23 | * @var string
24 | */
25 | protected $name = 'queue:listen';
26 |
27 | /**
28 | * @var string
29 | */
30 | protected $description = 'Listen to pushed queues';
31 |
32 | /**
33 | * Process a certain job.
34 | *
35 | * @param $job \Phalcon\Queue\Beanstalk\Job
36 | * @return bool
37 | */
38 | protected function processJob($job)
39 | {
40 | $body = $job->getBody();
41 |
42 | if (! isset($body['class'])) {
43 | return false;
44 | }
45 |
46 | $exclass = explode('@', $body['class']);
47 |
48 | $method = 'listener';
49 |
50 | if (isset($exclass[1])) {
51 | $method = $exclass[1];
52 | }
53 |
54 | (new $exclass[0])->{$method}($this, $job, $body['data']);
55 |
56 | return true;
57 | }
58 |
59 | /**
60 | * {@inheritdoc}
61 | */
62 | public function slash()
63 | {
64 | while (true) {
65 | try {
66 | while (($job = Queue::peekReady()) !== false) {
67 | $this->processJob($job);
68 | }
69 | } catch (Exception $e) {
70 | $this->exception($e);
71 | }
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/Clarity/Console/README.md:
--------------------------------------------------------------------------------
1 | # Clarity Console
2 |
3 | use this to build your own console command for your Phalcon applications.
4 |
5 | ## Console
6 |
7 | Let's create a simple console
8 |
9 | ```php
10 | comment('triggered!');
25 | }
26 | }
27 | ```
28 |
29 | Save the file as ``SampleConsole.php``
30 |
31 |
32 | ---
33 |
34 |
35 | ## Bootstrap
36 |
37 | Let's bootstrap the application on how we could probably create the executor.
38 |
39 | ```php
40 | #!/usr/bin/env php
41 | add(new $console);
59 | }
60 | }
61 |
62 | $app->run();
63 | ```
64 |
65 | Save the above code as ``console`` or any you want, while slayer is ``brood``.
66 |
67 | Run it to your console:
68 | ```shell
69 | php console
70 | ```
71 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Script/RunCommand.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Script;
12 |
13 | use Clarity\Console\CLI;
14 | use Clarity\Console\Brood;
15 | use Symfony\Component\Console\Input\InputArgument;
16 |
17 | /**
18 | * A console command that executes a script.
19 | */
20 | class RunCommand extends Brood
21 | {
22 | /**
23 | * {@inheritdoc}
24 | */
25 | protected $name = 'run';
26 |
27 | /**
28 | * {@inheritdoc}
29 | */
30 | protected $description = 'Automated scripts to be run.';
31 |
32 | /**
33 | * {@inheritdoc}
34 | */
35 | public function slash()
36 | {
37 | $script = $this->input->getArgument('script');
38 |
39 | $lists = config()->script->toArray();
40 |
41 | if (isset($lists[$script]) === false) {
42 | $this->error("\nWe can't find `".$script.'` in the lists of script.'."\n");
43 |
44 | return;
45 | }
46 |
47 | foreach ($lists[$script] as $selected) {
48 | if (is_callable($selected)) {
49 | CLI::handleCallback($selected);
50 | continue;
51 | }
52 |
53 | if (is_array($selected)) {
54 | CLI::bash($selected);
55 | continue;
56 | }
57 |
58 | CLI::process($selected);
59 | }
60 | }
61 |
62 | /**
63 | * {@inheritdoc}
64 | */
65 | protected function arguments()
66 | {
67 | return [
68 | ['script', InputArgument::REQUIRED, 'Automated script to be use'],
69 | ];
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Server/BenchmarkCommand.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Server;
12 |
13 | use Clarity\Console\Brood;
14 | use Symfony\Component\Console\Input\InputOption;
15 |
16 | /**
17 | * A console command that serves a module.
18 | */
19 | class BenchmarkCommand extends Brood
20 | {
21 | /**
22 | * {@inheritdoc}
23 | */
24 | protected $name = 'benchmark';
25 |
26 | /**
27 | * {@inheritdoc}
28 | */
29 | protected $description = 'Check the system benchmarking calls.';
30 |
31 | /**
32 | * {@inheritdoc}
33 | */
34 | public function slash()
35 | {
36 | $table = $this->table(
37 | ['Name', 'Time (sec)', 'Percentage'],
38 | $this->getBenchmarks()
39 | );
40 |
41 | $table->render();
42 | }
43 |
44 | public function getBenchmarks()
45 | {
46 | $records = [];
47 |
48 | $total_sec = 0;
49 |
50 | # iterate the markings
51 | foreach (resolve('benchmark')->get() as $name => $sec) {
52 | $total_sec += $sec;
53 |
54 | $records[] = [
55 | $name,
56 | $sec,
57 | 0,
58 | ];
59 | }
60 |
61 | # update percentage
62 | foreach ($records as $idx => $record) {
63 | $record[2] = number_format(($record[1] / $total_sec) * 100, 2);
64 | $records[$idx] = $record;
65 | }
66 |
67 | # add the total in the last record
68 | $records[] = [
69 | 'TOTAL',
70 | $total_sec,
71 | null
72 | ];
73 |
74 | return $records;
75 | }
76 |
77 | /**
78 | * {@inheritdoc}
79 | */
80 | protected function options()
81 | {
82 | return [];
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Server/ClutchCommand.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Server;
12 |
13 | use Psy\Shell;
14 | use Psy\Configuration;
15 | use Clarity\Console\Brood;
16 | use Symfony\Component\Console\Input\InputArgument;
17 |
18 | /**
19 | * A console command to interact with your application.
20 | */
21 | class ClutchCommand extends Brood
22 | {
23 | /**
24 | * brood commands to include in the clutch shell.
25 | *
26 | * @var array
27 | */
28 | protected $commandWhitelist = [
29 | 'env',
30 | 'optimize',
31 | 'clear:all', 'clear:cache', 'clear:compiled', 'clear:logs', 'clear:session', 'clear:views',
32 | 'db:migrate', 'db:status',
33 | ];
34 |
35 | /**
36 | * The console command name.
37 | *
38 | * @var string
39 | */
40 | protected $name = 'clutch';
41 |
42 | /**
43 | * {@inheritdoc}
44 | */
45 | protected $description = 'Interact with your application';
46 |
47 | /**
48 | * {@inheritdoc}
49 | */
50 | public function slash()
51 | {
52 | $this->getApplication()->setCatchExceptions(false);
53 |
54 | $config = new Configuration;
55 |
56 | $config->getPresenter()->addCasters(
57 | $this->getCasters()
58 | );
59 |
60 | $shell = new Shell($config);
61 | $shell->addCommands($this->getCommands());
62 | $shell->setIncludes($this->getInput()->getArgument('include'));
63 |
64 | $shell->run();
65 | }
66 |
67 | /**
68 | * Get clutch commands to pass through PsySH.
69 | *
70 | * @return array
71 | */
72 | protected function getCommands()
73 | {
74 | $commands = [];
75 |
76 | foreach ($this->getApplication()->all() as $name => $command) {
77 | if (in_array($name, $this->commandWhitelist)) {
78 | $commands[] = $command;
79 | }
80 | }
81 |
82 | return $commands;
83 | }
84 |
85 | /**
86 | * Get all casters.
87 | *
88 | * @return array
89 | */
90 | protected function getCasters()
91 | {
92 | // todo
93 | return [];
94 | }
95 |
96 | /**
97 | * Get the console command arguments.
98 | *
99 | * @return array
100 | */
101 | protected function arguments()
102 | {
103 | return [
104 | ['include', InputArgument::IS_ARRAY, 'Include file(s) before starting clutch'],
105 | ];
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Server/EnvCommand.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Server;
12 |
13 | use Clarity\Console\Brood;
14 |
15 | /**
16 | * A console command that determines the current environment.
17 | */
18 | class EnvCommand extends Brood
19 | {
20 | /**
21 | * {@inheritdoc}
22 | */
23 | protected $name = 'env';
24 |
25 | /**
26 | * {@inheritdoc}
27 | */
28 | protected $description = 'Get current environment';
29 |
30 | /**
31 | * {@inheritdoc}
32 | */
33 | public function slash()
34 | {
35 | $timeout = $this->getInput()->getOption('timeout');
36 |
37 | $this->info(
38 | "\n".'Your current environment ['.config()->environment.']'."\n"
39 | // .' | Timeout: '.$timeout
40 | );
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Server/ServeCommand.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Server;
12 |
13 | use Clarity\Console\Brood;
14 | use Symfony\Component\Console\Input\InputOption;
15 |
16 | /**
17 | * A console command that serves a module.
18 | */
19 | class ServeCommand extends Brood
20 | {
21 | /**
22 | * {@inheritdoc}
23 | */
24 | protected $name = 'serve';
25 |
26 | /**
27 | * {@inheritdoc}
28 | */
29 | protected $description = 'Serve the application on the PHP development server';
30 |
31 | /**
32 | * {@inheritdoc}
33 | */
34 | public function slash()
35 | {
36 | chdir(url_trimmer(config()->path->root.'public'));
37 | $current_dir = getcwd();
38 |
39 | $host = $this->input->getOption('host');
40 | $port = $this->input->getOption('port');
41 | $file = $current_dir.'/'.$this->input->getOption('file');
42 |
43 | $this->info("Phalcon Slayer development server started on http://{$host}:{$port}/");
44 |
45 | passthru(PHP_BINARY." -S {$host}:{$port} -t {$current_dir} {$file}");
46 | }
47 |
48 | /**
49 | * {@inheritdoc}
50 | */
51 | protected function options()
52 | {
53 | $host = '0.0.0.0';
54 | $port = 8080;
55 |
56 | if (getenv('SERVE_HOST')) {
57 | $host = getenv('SERVE_HOST');
58 | }
59 |
60 | if (getenv('SERVE_PORT')) {
61 | $port = getenv('SERVE_PORT');
62 | }
63 |
64 | return [
65 | [
66 | 'host',
67 | null,
68 | InputOption::VALUE_OPTIONAL,
69 | 'The host address to serve the application on.',
70 | $host,
71 | ],
72 | [
73 | 'port',
74 | null,
75 | InputOption::VALUE_OPTIONAL,
76 | 'The port to serve the application on.',
77 | $port,
78 | ],
79 | [
80 | 'file',
81 | null,
82 | InputOption::VALUE_OPTIONAL,
83 | 'The php file to be used.',
84 | 'index.php',
85 | ],
86 | ];
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Vendor/PublishCommand.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console\Vendor;
12 |
13 | use Exception;
14 | use Clarity\Console\Brood;
15 | use Symfony\Component\Console\Input\InputOption;
16 | use Symfony\Component\Console\Input\InputArgument;
17 |
18 | /**
19 | * A console command that publishes a vendor's contents/files/configurations.
20 | */
21 | class PublishCommand extends Brood
22 | {
23 | /**
24 | * {@inheritdoc}
25 | */
26 | protected $name = 'vendor:publish';
27 |
28 | /**
29 | * {@inheritdoc}
30 | */
31 | protected $description = 'Publish a vendor package';
32 |
33 | /**
34 | * {@inheritdoc}
35 | */
36 | public function slash()
37 | {
38 | $tag_name = $this->input->getOption('tag');
39 | $alias = $this->input->getArgument('alias');
40 |
41 | foreach (config()->app->services as $service) {
42 | $obj = new $service;
43 |
44 | if ($alias != $obj->getAlias()) {
45 | continue;
46 | }
47 |
48 | $obj->boot();
49 |
50 | try {
51 | $tags = $obj->getToBePublished($tag_name);
52 |
53 | foreach ($tags as $tag_name => $tag) {
54 | foreach ($tag as $source => $dest) {
55 | $are_you_sure = 'Are you sure you want to '.
56 | 'publish "'.$tag_name.'"? [y/n]: ';
57 |
58 | if (! $this->confirm($are_you_sure)) {
59 | continue;
60 | }
61 |
62 | cp($source, $dest);
63 |
64 | $this->info("Publishing tag \"$tag_name\" from [$source] to [$dest]");
65 | }
66 | }
67 | } catch (Exception $e) {
68 | $this->error($e->getMessage());
69 | }
70 | }
71 | }
72 |
73 | /**
74 | * {@inheritdoc}
75 | */
76 | public function arguments()
77 | {
78 | return [
79 | ['alias', InputArgument::REQUIRED, 'Provider alias'],
80 | ];
81 | }
82 |
83 | /**
84 | * {@inheritdoc}
85 | */
86 | protected function options()
87 | {
88 | return [
89 | [
90 | 'tag',
91 | null,
92 | InputOption::VALUE_OPTIONAL,
93 | 'Specify which tag you want to publish',
94 | null,
95 | ],
96 | ];
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/Clarity/Console/Vendor/stubs/ServiceProvider.stub:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Contracts\Flysystem;
12 |
13 | /**
14 | * An adapter interface for flysystem.
15 | */
16 | interface AdapterInterface
17 | {
18 | /**
19 | * Get the adapter.
20 | *
21 | * @return mixed
22 | */
23 | public function getAdapter();
24 | }
25 |
--------------------------------------------------------------------------------
/src/Clarity/Contracts/Mail/MailInterface.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Contracts\Mail;
12 |
13 | /**
14 | * A mail interface for adapter handling.
15 | */
16 | interface MailInterface
17 | {
18 | /**
19 | * Attach a file.
20 | *
21 | * @param string $file The file to be attached
22 | */
23 | public function attach($file);
24 |
25 | /**
26 | * Set the encryption type.
27 | *
28 | * @param string $encryption The encryption method
29 | */
30 | public function encryption($encryption);
31 |
32 | /**
33 | * Set the host of your mail provider.
34 | *
35 | * @param string $host The smtp host
36 | */
37 | public function host($host);
38 |
39 | /**
40 | * Set the port of your mail provider.
41 | *
42 | * @param string $port The smtp port
43 | */
44 | public function port($port);
45 |
46 | /**
47 | * Set the username of your mail provider.
48 | *
49 | * @param string $username The smtp username
50 | */
51 | public function username($username);
52 |
53 | /**
54 | * Set the password of your mail provider.
55 | *
56 | * @param string $password The smtp password
57 | */
58 | public function password($password);
59 |
60 | /**
61 | * The email who acts as the sender.
62 | *
63 | * @param string $email The sender email
64 | */
65 | public function from($email);
66 |
67 | /**
68 | * The email(s) who acts as the receiver(s).
69 | *
70 | * @param mixed $emails The lists of emails to send
71 | */
72 | public function to(array $emails);
73 |
74 | /**
75 | * The email(s) who acts as the blind carbon copy receiver(s).
76 | *
77 | * @param mixed $emails The lists of emails to send as blind carbon copy
78 | */
79 | public function bcc(array $emails);
80 |
81 | /**
82 | * The email(s) who acts as the carbon copy receiver(s).
83 | *
84 | * @param mixed $emails The lists of emails to send as carbon copy
85 | */
86 | public function cc(array $emails);
87 |
88 | /**
89 | * Set the subject of your email.
90 | *
91 | * @param string $subject The mail subject or title
92 | */
93 | public function subject($subject);
94 |
95 | /**
96 | * Set the content of your email.
97 | *
98 | * @param string $body The mail content or body
99 | */
100 | public function body($body);
101 |
102 | /**
103 | * This function will be triggered upon sending.
104 | */
105 | public function send();
106 | }
107 |
--------------------------------------------------------------------------------
/src/Clarity/Contracts/Providers/ModuleInterface.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Contracts\Providers;
12 |
13 | use Phalcon\Di;
14 |
15 | /**
16 | * A provider interface, dedicated for module insertion.
17 | */
18 | interface ModuleInterface
19 | {
20 | /**
21 | * Execute scripts after module run.
22 | *
23 | * @return void
24 | */
25 | public function afterModuleRun();
26 | }
27 |
--------------------------------------------------------------------------------
/src/Clarity/Contracts/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "clarity/contracts",
3 | "description": "",
4 | "license": "MIT",
5 | "homepage": "http://github.com/ps-clarity/contracts",
6 | "support": {
7 | "issues": "https://github.com/ps-clarity/contracts/issues",
8 | "source": "https://github.com/ps-clarity/contracts"
9 | },
10 | "authors": [
11 | {
12 | "name": "Daison Carino",
13 | "email": "daison12006013@gmail.com"
14 | }
15 | ],
16 | "autoload": {
17 | "psr-4": {
18 | "Clarity\\Contracts\\": ""
19 | }
20 | },
21 | "extra": {
22 | "branch-alias": {
23 | "dev-master": "1.4-dev"
24 | }
25 | },
26 | "minimum-stability": "dev"
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Exceptions/AccessNotAllowedException.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Exceptions;
12 |
13 | /**
14 | * An exception known for CSRF/Unwanted access.
15 | */
16 | class AccessNotAllowedException extends Handler
17 | {
18 | }
19 |
--------------------------------------------------------------------------------
/src/Clarity/Exceptions/ControllerNotFoundException.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Exceptions;
12 |
13 | /**
14 | * An exception known for Controller or Action not found.
15 | */
16 | class ControllerNotFoundException extends Handler
17 | {
18 | }
19 |
--------------------------------------------------------------------------------
/src/Clarity/Exceptions/FileNotFoundException.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Exceptions;
12 |
13 | /**
14 | * An exception known for File not found.
15 | */
16 | class FileNotFoundException extends Handler
17 | {
18 | }
19 |
--------------------------------------------------------------------------------
/src/Clarity/Exceptions/ServiceAliasNotFoundException.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Exceptions;
12 |
13 | /**
14 | * An exception known when a service provider does not have an alias.
15 | */
16 | class ServiceAliasNotFoundException extends Handler
17 | {
18 | }
19 |
--------------------------------------------------------------------------------
/src/Clarity/Exceptions/ViewFileNotFoundException.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Exceptions;
12 |
13 | /**
14 | * An exception known for not found View Templates.
15 | */
16 | class ViewFileNotFoundException extends Handler
17 | {
18 | }
19 |
--------------------------------------------------------------------------------
/src/Clarity/Exceptions/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "clarity/exceptions",
3 | "description": "",
4 | "license": "MIT",
5 | "homepage": "http://github.com/ps-clarity/exceptions",
6 | "support": {
7 | "issues": "https://github.com/ps-clarity/exceptions/issues",
8 | "source": "https://github.com/ps-clarity/exceptions"
9 | },
10 | "authors": [
11 | {
12 | "name": "Daison Carino",
13 | "email": "daison12006013@gmail.com"
14 | }
15 | ],
16 | "require": {
17 | "monolog/monolog": "^1.15",
18 | "symfony/debug": "^2.7"
19 | },
20 | "autoload": {
21 | "psr-4": {
22 | "Clarity\\Exceptions\\": ""
23 | }
24 | },
25 | "extra": {
26 | "branch-alias": {
27 | "dev-master": "1.4-dev"
28 | }
29 | },
30 | "minimum-stability": "dev"
31 | }
32 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/Auth.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'auth'.
15 | */
16 | class Auth extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'auth';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/BehatMink.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'behat_mink'.
15 | */
16 | class BehatMink extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'behat_mink';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/Cache.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'cache'.
15 | */
16 | class Cache extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'cache';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/Config.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'config'.
15 | */
16 | class Config extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'config';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/Crypt.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'crypt'.
15 | */
16 | class Crypt extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'crypt';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/DB.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'db'.
15 | */
16 | class DB extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'db';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/Filter.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'filter'.
15 | */
16 | class Filter extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'filter';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/Flash.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'flash'.
15 | */
16 | class Flash extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'flash';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/Flysystem.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'flysystem'.
15 | */
16 | class Flysystem extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'flysystem';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/FlysystemManager.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'flysystem_manager'.
15 | *
16 | * @see League\Flysystem\MountManager for available methods
17 | *
18 | * @method mountFilesystems(array $filesystems)
19 | * @method mountFilesystem($prefix, League\Flysystem\FilesystemInterface $filesystem)
20 | * @method getFilesystem(string $adapter)
21 | * @method filterPrefix(array $arguments)
22 | * @method listContents($directory = '', $recursive = false)
23 | * @method copy($from, $to)
24 | * @method listWith(array $keys = [], $directory = '', $recursive = false)
25 | * @method move($from, $to)
26 | * @method invokePluginOnFilesystem($method, $arguments, $prefix)
27 | */
28 | class FlysystemManager extends Facade
29 | {
30 | /**
31 | * {@inheritdoc}
32 | */
33 | protected static function getFacadeAccessor()
34 | {
35 | return 'flysystem_manager';
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/Log.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'log'.
15 | */
16 | class Log extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'log';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/Queue.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'queue'.
15 | */
16 | class Queue extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'queue';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/Redirect.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'redirect'.
15 | */
16 | class Redirect extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'redirect';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/Request.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'request'.
15 | */
16 | class Request extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'request';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/Response.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'response'.
15 | */
16 | class Response extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'response';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/Route.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'route'.
15 | */
16 | class Route extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'router';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/Security.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'security'.
15 | */
16 | class Security extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'security';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/Session.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'session'.
15 | */
16 | class Session extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'session';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/Tag.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'tag'.
15 | */
16 | class Tag extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'tag';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/URL.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'url'.
15 | */
16 | class URL extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'url';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/Validator.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'validator'.
15 | */
16 | class Validator extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'validator';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/View.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Facades;
12 |
13 | /**
14 | * This is the facade calling the alias 'view'.
15 | */
16 | class View extends Facade
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected static function getFacadeAccessor()
22 | {
23 | return 'view';
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Facades/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "clarity/facades",
3 | "description": "",
4 | "license": "MIT",
5 | "homepage": "http://github.com/ps-clarity/facades",
6 | "support": {
7 | "issues": "https://github.com/ps-clarity/facades/issues",
8 | "source": "https://github.com/ps-clarity/facades"
9 | },
10 | "authors": [
11 | {
12 | "name": "Daison Carino",
13 | "email": "daison12006013@gmail.com"
14 | }
15 | ],
16 | "autoload": {
17 | "psr-4": {
18 | "Clarity\\Facades\\": ""
19 | }
20 | },
21 | "extra": {
22 | "branch-alias": {
23 | "dev-master": "1.4-dev"
24 | }
25 | },
26 | "minimum-stability": "dev"
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Kernel/Kernel.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Kernel;
12 |
13 | /**
14 | * Acts like a manager that initializes all the configurations/environments and module.
15 | */
16 | class Kernel
17 | {
18 | use KernelTrait;
19 |
20 | /**
21 | * The dependency injection.
22 | *
23 | * @var \Phalcon\DiInterface
24 | */
25 | private $di;
26 |
27 | /**
28 | * The configured environment.
29 | *
30 | * @var string
31 | */
32 | private $env;
33 |
34 | /**
35 | * The path provided.
36 | *
37 | * @var mixed
38 | */
39 | private $paths;
40 |
41 | /**
42 | * Set the paths.
43 | *
44 | * @param mixed $paths
45 | * @return \Clarity\Kernel\Kernel
46 | */
47 | public function setPaths($paths)
48 | {
49 | $this->paths = $paths;
50 |
51 | if (is_cli()) {
52 | resolve('benchmark')->here('Setting Paths');
53 | }
54 |
55 | return $this;
56 | }
57 |
58 | /**
59 | * Set the environment.
60 | *
61 | * @param string $env
62 | * @return \Clarity\Kernel\Kernel
63 | */
64 | public function setEnvironment($env)
65 | {
66 | $this->env = $env;
67 |
68 | if (is_cli()) {
69 | resolve('benchmark')->here('Setting Environment');
70 | }
71 |
72 | return $this;
73 | }
74 |
75 | /**
76 | * Get the environment.
77 | *
78 | * @return string Current environment
79 | */
80 | public function getEnvironment()
81 | {
82 | return $this->env;
83 | }
84 |
85 | /**
86 | * Register modules.
87 | *
88 | * @return mixed
89 | */
90 | public function modules()
91 | {
92 | config(['modules' => $this->di->get('module')->all()]);
93 |
94 | $this->di->get('application')->registerModules(config()->modules->toArray());
95 |
96 | if (is_cli()) {
97 | resolve('benchmark')->here('Registering All Modules');
98 | }
99 |
100 | return $this;
101 | }
102 |
103 | /**
104 | * Render the system content.
105 | */
106 | public function render()
107 | {
108 | echo $this->di->get('application')->handle()->getContent();
109 | }
110 |
111 | /**
112 | * Here, you will be loading the system by defining the module.
113 | *
114 | * @param string $module_name The module name
115 | * @return mixed
116 | */
117 | public function run($module_name)
118 | {
119 | $this->di->get('application')->setDefaultModule($module_name);
120 |
121 | $this->di->get($module_name)->afterModuleRun();
122 |
123 | return $this;
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/src/Clarity/Kernel/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "clarity/kernel",
3 | "description": "",
4 | "license": "MIT",
5 | "homepage": "http://github.com/ps-clarity/kernel",
6 | "support": {
7 | "issues": "https://github.com/ps-clarity/kernel/issues",
8 | "source": "https://github.com/ps-clarity/kernel"
9 | },
10 | "authors": [
11 | {
12 | "name": "Daison Carino",
13 | "email": "daison12006013@gmail.com"
14 | }
15 | ],
16 | "require": {
17 | "clarity/support": "1.4.*",
18 | "symfony/console": "^2.7",
19 | "league/flysystem": "^1.0",
20 | "monolog/monolog": "^1.15"
21 | },
22 | "autoload": {
23 | "psr-4": {
24 | "Clarity\\Kernel\\": ""
25 | }
26 | },
27 | "extra": {
28 | "branch-alias": {
29 | "dev-master": "1.4-dev"
30 | }
31 | },
32 | "minimum-stability": "dev"
33 | }
34 |
--------------------------------------------------------------------------------
/src/Clarity/Lang/LangFacade.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Lang;
12 |
13 | use Clarity\Facades\Facade;
14 |
15 | /**
16 | * The 'lang' Facade.
17 | */
18 | class LangFacade extends Facade
19 | {
20 | /**
21 | * {@inheritdoc}
22 | */
23 | protected static function getFacadeAccessor()
24 | {
25 | return 'lang';
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Lang/LangServiceProvider.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Lang;
12 |
13 | use Clarity\Providers\ServiceProvider;
14 |
15 | /**
16 | * The 'lang' service provider.
17 | */
18 | class LangServiceProvider extends ServiceProvider
19 | {
20 | /**
21 | * {@inheritdoc}
22 | */
23 | public function register()
24 | {
25 | $this->app->singleton('lang', function () {
26 | $language = config()->app->lang;
27 |
28 | $translation = new Lang();
29 | $translation
30 | ->setLanguage($language)
31 | ->setLangDir(config()->path->lang);
32 |
33 | return $translation;
34 | });
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Clarity/Lang/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "clarity/lang",
3 | "description": "",
4 | "license": "MIT",
5 | "homepage": "http://github.com/ps-clarity/lang",
6 | "support": {
7 | "issues": "https://github.com/ps-clarity/lang/issues",
8 | "source": "https://github.com/ps-clarity/lang"
9 | },
10 | "authors": [
11 | {
12 | "name": "Daison Carino",
13 | "email": "daison12006013@gmail.com"
14 | }
15 | ],
16 | "require": {
17 | },
18 | "autoload": {
19 | "psr-4": {
20 | "Clarity\\Lang\\": ""
21 | }
22 | },
23 | "extra": {
24 | "branch-alias": {
25 | "dev-master": "1.4-dev"
26 | }
27 | },
28 | "minimum-stability": "dev"
29 | }
30 |
--------------------------------------------------------------------------------
/src/Clarity/Mail/MailFacade.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Mail;
12 |
13 | use Clarity\Facades\Facade;
14 |
15 | /**
16 | * The 'mail' Facade.
17 | */
18 | class MailFacade extends Facade
19 | {
20 | /**
21 | * {@inheritdoc}
22 | */
23 | protected static function getFacadeAccessor()
24 | {
25 | return 'mail';
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Mail/MailServiceProvider.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Mail;
12 |
13 | use Exception;
14 | use Clarity\Providers\ServiceProvider;
15 |
16 | /**
17 | * The 'mail' service provider.
18 | */
19 | class MailServiceProvider extends ServiceProvider
20 | {
21 | /**
22 | * @var bool
23 | */
24 | protected $defer = true;
25 |
26 | /**
27 | * Get all this service provider provides.
28 | *
29 | * @return array
30 | */
31 | public function provides()
32 | {
33 | return ['mail.selected_adapter', 'mail'];
34 | }
35 |
36 | /**
37 | * {@inheritdoc}
38 | */
39 | public function register()
40 | {
41 | $this->app->singleton('mail.selected_adapter', function () {
42 | $selected_adapter = config()->app->mail_adapter;
43 |
44 | return config()->mail->{$selected_adapter};
45 | });
46 |
47 | $this->app->singleton('mail', function ($app) {
48 | $adapter = $app->make('mail.selected_adapter')->toArray();
49 |
50 | if (! $adapter) {
51 | throw new Exception('Adapter not found.');
52 | }
53 |
54 | if (! $adapter['active']) {
55 | return $this;
56 | }
57 |
58 | $class = $adapter['class'];
59 |
60 | return new Mail(new $class, $adapter['options']);
61 | });
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/Clarity/Mail/SwiftMailer/MailMailer.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Mail\SwiftMailer;
12 |
13 | /**
14 | * A swift mail adapter.
15 | */
16 | class MailMailer extends Swift
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected function getTransport()
22 | {
23 | return \Swift_MailTransport::newInstance();
24 | }
25 |
26 | /**
27 | * {@inheritdoc}
28 | */
29 | public function encryption($encryption)
30 | {
31 | return $this;
32 | }
33 |
34 | /**
35 | * {@inheritdoc}
36 | */
37 | public function host($host)
38 | {
39 | return $this;
40 | }
41 |
42 | /**
43 | * {@inheritdoc}
44 | */
45 | public function port($port)
46 | {
47 | return $this;
48 | }
49 |
50 | /**
51 | * {@inheritdoc}
52 | */
53 | public function username($username)
54 | {
55 | return $this;
56 | }
57 |
58 | /**
59 | * {@inheritdoc}
60 | */
61 | public function password($password)
62 | {
63 | return $this;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/Clarity/Mail/SwiftMailer/SendmailMailer.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Mail\SwiftMailer;
12 |
13 | /**
14 | * A swift sendmail adapter.
15 | */
16 | class SendmailMailer extends Swift
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected function getTransport()
22 | {
23 | $path = config('services.sendmail', '/usr/sbin/sendmail -bs');
24 |
25 | return \Swift_SendmailTransport::newInstance($path);
26 | }
27 |
28 | /**
29 | * {@inheritdoc}
30 | */
31 | public function encryption($encryption)
32 | {
33 | return $this;
34 | }
35 |
36 | /**
37 | * {@inheritdoc}
38 | */
39 | public function host($host)
40 | {
41 | return $this;
42 | }
43 |
44 | /**
45 | * {@inheritdoc}
46 | */
47 | public function port($port)
48 | {
49 | return $this;
50 | }
51 |
52 | /**
53 | * {@inheritdoc}
54 | */
55 | public function username($username)
56 | {
57 | return $this;
58 | }
59 |
60 | /**
61 | * {@inheritdoc}
62 | */
63 | public function password($password)
64 | {
65 | return $this;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/Clarity/Mail/SwiftMailer/SmtpMailer.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Mail\SwiftMailer;
12 |
13 | /**
14 | * A swift smtp adapter.
15 | */
16 | class SmtpMailer extends Swift
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | protected function getTransport()
22 | {
23 | return \Swift_SmtpTransport::newInstance();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Mail/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "clarity/mail",
3 | "description": "",
4 | "license": "MIT",
5 | "homepage": "http://github.com/ps-clarity/mail",
6 | "support": {
7 | "issues": "https://github.com/ps-clarity/mail/issues",
8 | "source": "https://github.com/ps-clarity/mail"
9 | },
10 | "authors": [
11 | {
12 | "name": "Daison Carino",
13 | "email": "daison12006013@gmail.com"
14 | }
15 | ],
16 | "require": {},
17 | "autoload": {
18 | "psr-4": {
19 | "Clarity\\Mail\\": ""
20 | }
21 | },
22 | "extra": {
23 | "branch-alias": {
24 | "dev-master": "1.4-dev"
25 | }
26 | },
27 | "minimum-stability": "dev"
28 | }
29 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Aliaser.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | /**
14 | * This provider manages all class aliases.
15 | */
16 | class Aliaser extends ServiceProvider
17 | {
18 | /**
19 | * {@inheridoc}.
20 | */
21 | public function register()
22 | {
23 | $this->app->singleton('aliaser', function () {
24 | foreach (config('app.aliases') as $alias => $class) {
25 | if (! class_exists($alias)) {
26 | \Clarity\Services\Mapper::classAlias($class, $alias);
27 | }
28 | }
29 | });
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Annotations.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Phalcon\Annotations\Adapter\Memory;
14 |
15 | /**
16 | * Get the 'annotations' service provider.
17 | */
18 | class Annotations extends ServiceProvider
19 | {
20 | /**
21 | * {@inheridoc}.
22 | */
23 | public function register()
24 | {
25 | $this->app->instance('annotations', new Memory, $singleton = true);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Application.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Clarity\Facades\Facade;
14 | use Clarity\Support\Phalcon\Mvc\Application as BaseApplication;
15 |
16 | /**
17 | * This provider handles the @see \Phalcon\Mvc\Application
18 | * and also having an option to add a module.
19 | */
20 | class Application extends ServiceProvider
21 | {
22 | /**
23 | * {@inheridoc}.
24 | */
25 | public function register()
26 | {
27 | $this->app->singleton('application', function () {
28 | $instance = new BaseApplication($this->getDI());
29 |
30 | Facade::setFacadeApplication($instance);
31 |
32 | return $instance;
33 | });
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Auth.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Clarity\Support\Auth\Auth as BaseAuth;
14 |
15 | /**
16 | * This provider handles the general authentication.
17 | */
18 | class Auth extends ServiceProvider
19 | {
20 | /**
21 | * {@inheridoc}.
22 | */
23 | public function register()
24 | {
25 | $this->app->instance('auth', new BaseAuth, $singleton = true);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/BehatMink.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Clarity\TestSuite\Behat\Mink\Mink;
14 |
15 | /**
16 | * This provider instantiates the testing tool behat/mink, that by
17 | * default having the adapters to parse html requests.
18 | */
19 | class BehatMink extends ServiceProvider
20 | {
21 | /**
22 | * {@inheridoc}.
23 | */
24 | public function register()
25 | {
26 | $this->app->singleton('behat_mink', function () {
27 | $adapters = config()->test_suite->behat->adapters->toArray();
28 |
29 | return new Mink($adapters);
30 | });
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Cache.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | /**
14 | * This provider manages the cache drivers.
15 | */
16 | class Cache extends ServiceProvider
17 | {
18 | /**
19 | * Get the selected cache adapter.
20 | *
21 | * @return string
22 | */
23 | private function getSelectedAdapter()
24 | {
25 | return config()->app->cache_adapter;
26 | }
27 |
28 | /**
29 | * {@inheridoc}.
30 | */
31 | public function register()
32 | {
33 | $this->app->singleton('cache', function () {
34 | $adapter = config()->cache->adapters->{$this->getSelectedAdapter()};
35 |
36 | $backend = $adapter->backend;
37 | $frontend = $adapter->frontend;
38 |
39 | $front_cache = new $frontend([
40 | 'lifetime' => $adapter->lifetime,
41 | ]);
42 |
43 | return new $backend($front_cache, $adapter->options->toArray());
44 | });
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/CollectionManager.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Phalcon\Mvc\Collection\Manager as BaseCollectionManager;
14 |
15 | /**
16 | * This provider controls the initialization of models, keeping record
17 | * of relations between the different models of the application.
18 | */
19 | class CollectionManager extends ServiceProvider
20 | {
21 | /**
22 | * {@inheridoc}.
23 | */
24 | public function register()
25 | {
26 | $this->app->instance(
27 | 'collectionManager',
28 | new BaseCollectionManager,
29 | $singleton = true
30 | );
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Console.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Symfony\Component\Console\Application as ConsoleApplication;
14 |
15 | /**
16 | * This provider register all the assigned consoles which basically
17 | * manages them and injecting those to be part of the commands.
18 | */
19 | class Console extends ServiceProvider
20 | {
21 | /**
22 | * The current system version.
23 | */
24 | const VERSION = 'v1.5.x-dev';
25 |
26 | /**
27 | * The console description which holds the copywright.
28 | */
29 | const DESCRIPTION = 'Brood (c) Daison Cariño';
30 |
31 | /**
32 | * @var bool
33 | */
34 | protected $defer = true;
35 |
36 | /**
37 | * Get all this service provider provides.
38 | *
39 | * @return array
40 | */
41 | public function provides()
42 | {
43 | return ['console'];
44 | }
45 |
46 | /**
47 | * {@inheridoc}.
48 | */
49 | public function register()
50 | {
51 | $this->app->bind('console', function () {
52 | $app = new ConsoleApplication(static::DESCRIPTION, static::VERSION);
53 |
54 | if (is_cli()) {
55 | foreach (config()->consoles as $console) {
56 | $app->add(new $console);
57 | }
58 | }
59 |
60 | return $app;
61 | });
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Cookies.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Phalcon\Http\Response\Cookies as BaseCookies;
14 |
15 | /**
16 | * Get the 'cookies' service provider.
17 | */
18 | class Cookies extends ServiceProvider
19 | {
20 | /**
21 | * {@inheridoc}.
22 | */
23 | public function register()
24 | {
25 | $this->app->instance('cookies', new BaseCookies, $singleton = true);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Crypt.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Phalcon\Version;
14 | use Illuminate\Support\Str;
15 | use Clarity\Support\Phalcon\Crypt as BaseCrypt;
16 |
17 | /**
18 | * This provides encryption facilities to phalcon applications.
19 | */
20 | class Crypt extends ServiceProvider
21 | {
22 | /**
23 | * {@inheridoc}.
24 | */
25 | public function register()
26 | {
27 | $this->app->singleton('crypt', function () {
28 | $crypt = new BaseCrypt();
29 |
30 | if (Str::startsWith($key = config('app.encryption.key'), 'base64:')) {
31 | $key = base64_decode(substr($key, 7));
32 | }
33 |
34 | $crypt->setKey($key);
35 | $crypt->setCipher(config('app.encryption.cipher'));
36 |
37 | if ((int) Version::getId() <= 2001341) {
38 | $crypt->setMode(config('app.encryption.mode'));
39 | }
40 |
41 | return $crypt;
42 | });
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Dispatcher.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Clarity\Exceptions\ControllerNotFoundException;
14 | use Clarity\Support\Phalcon\Events\Manager as PhalconEventsManager;
15 | use Clarity\Support\Phalcon\Mvc\Dispatcher as PhalconMvcDispatcher;
16 | use Phalcon\Mvc\Dispatcher\Exception as DispatchException;
17 |
18 | /**
19 | * This provider dispatch/process of taking the request object, extracting the
20 | * module name, controller name, action name, and optional parameters
21 | * contained in it, and then instantiating a controller and calling an
22 | * action of that controller.
23 | */
24 | class Dispatcher extends ServiceProvider
25 | {
26 | /**
27 | * {@inheridoc}.
28 | */
29 | protected $alias = 'dispatcher';
30 |
31 | /**
32 | * {@inheridoc}.
33 | */
34 | protected $shared = true;
35 |
36 | /**
37 | * {@inheridoc}.
38 | */
39 | public function boot()
40 | {
41 | $dispatcher = $this->getDI()->get('dispatcher');
42 |
43 | $event_manager = new PhalconEventsManager;
44 |
45 | $event_manager->attach('dispatch:beforeException',
46 | function ($event, $dispatcher, $exception) {
47 | if ($exception instanceof DispatchException) {
48 | throw new ControllerNotFoundException(
49 | $exception->getMessage()
50 | );
51 | }
52 | }
53 | );
54 |
55 | $dispatcher->setEventsManager($event_manager);
56 | }
57 |
58 | /**
59 | * Override the default controller suffix.
60 | *
61 | * @return string
62 | */
63 | public function getControllerSuffix()
64 | {
65 | return 'Controller';
66 | }
67 |
68 | /**
69 | * Override the default action suffix.
70 | *
71 | * @return string
72 | */
73 | public function getActionSuffix()
74 | {
75 | return 'Action';
76 | }
77 |
78 | /**
79 | * {@inheridoc}.
80 | */
81 | public function register()
82 | {
83 | $this->app->singleton('dispatcher', function () {
84 | $dispatcher = new PhalconMvcDispatcher();
85 |
86 | $dispatcher->setDefaultNamespace('App\Controllers');
87 | $dispatcher->setControllerSuffix($this->getControllerSuffix());
88 | $dispatcher->setActionSuffix($this->getActionSuffix());
89 |
90 | return $dispatcher;
91 | });
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Escaper.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Phalcon\Escaper as BaseEscaper;
14 |
15 | /**
16 | * Get the 'escaper' service provider.
17 | */
18 | class Escaper extends ServiceProvider
19 | {
20 | /**
21 | * {@inheridoc}.
22 | */
23 | public function register()
24 | {
25 | $this->app->instance('escaper', new BaseEscaper, $singleton = true);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/EventsManager.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Phalcon\Events\Manager;
14 |
15 | /**
16 | * Get the 'eventsManager' service provider.
17 | */
18 | class EventsManager extends ServiceProvider
19 | {
20 | /**
21 | * {@inheridoc}.
22 | */
23 | public function register()
24 | {
25 | $this->app->instance('eventsManager', new Manager, $singleton = true);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Filter.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Phalcon\Filter as BaseFilter;
14 |
15 | /**
16 | * This provider handles the filter component of Phalcon Framework.
17 | *
18 | * Sanitizing is the process which removes specific characters from a value,
19 | * that are not required or desired by the user or application.
20 | * By sanitizing input we ensure that application integrity will be intact.
21 | */
22 | class Filter extends ServiceProvider
23 | {
24 | /**
25 | * {@inheridoc}.
26 | */
27 | public function register()
28 | {
29 | $this->app->instance('filter', new BaseFilter, $singleton = true);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Flash.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Phalcon\Flash\Direct as PhalconFlashDirect;
14 | use Phalcon\Flash\Session as PhalconFlashSession;
15 |
16 | /**
17 | * This component helps to separate session data into “namespaces”.
18 | * Working by this way you can easily create groups of session variables into the application.
19 | */
20 | class Flash extends ServiceProvider
21 | {
22 | /**
23 | * The elements.
24 | *
25 | * @var array
26 | */
27 | protected $elements = [
28 | // 'error' => 'alert alert-danger',
29 | // 'success' => 'alert alert-success',
30 | // 'notice' => 'alert alert-info',
31 | // 'warning' => 'alert alert-warning',
32 | ];
33 |
34 | /**
35 | * {@inheridoc}.
36 | */
37 | public function register()
38 | {
39 | # this will be as $this->getDI()->get('flash.direct');
40 | $this->app->singleton('flash.direct', function () {
41 | $flash = new PhalconFlashDirect($this->elements);
42 |
43 | # setAutoescape is only available for >= 2.1.x Phalcon Version
44 | if (method_exists($flash, 'setAutoescape')) {
45 | $flash->setAutoescape(false);
46 | }
47 |
48 | return $flash;
49 | });
50 |
51 | # this will be as $this->getDI()->get('flash.session');
52 | $this->app->singleton('flash.session', function () {
53 | $flash = new PhalconFlashSession($this->elements);
54 |
55 | # setAutoescape is only available for >= 2.1.x Phalcon Version
56 | if (method_exists($flash, 'setAutoescape')) {
57 | $flash->setAutoescape(false);
58 | }
59 |
60 | return $flash;
61 | });
62 |
63 | $this->app->instance('flash', $this, $singleton = true);
64 | }
65 |
66 | /**
67 | * Get direct based flash.
68 | *
69 | * @return mixed \Phalcon\Flash\Direct
70 | */
71 | public function direct()
72 | {
73 | return $this->app->make('flash.direct');
74 | }
75 |
76 | /**
77 | * Get session based flash.
78 | *
79 | * @return mixed \Phalcon\Flash\Session
80 | */
81 | public function session()
82 | {
83 | return $this->app->make('flash.session');
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Flysystem.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use League\Flysystem\Filesystem;
14 | use League\Flysystem\MountManager;
15 |
16 | /**
17 | * This provider manages all available file system adapters such as local, aws
18 | * copy, ftp, rackspace and more.
19 | */
20 | class Flysystem extends ServiceProvider
21 | {
22 | /**
23 | * @var bool
24 | */
25 | protected $defer = true;
26 |
27 | /**
28 | * {@inheridoc}.
29 | */
30 | public function register()
31 | {
32 | $this->app->singleton('flysystem_manager', function () {
33 | $flies = [];
34 |
35 | foreach (config('flysystem') as $prefix => $fly) {
36 | $instance = new $fly['class']($fly['config']->toArray());
37 |
38 | $flies[$prefix] = new Filesystem($instance->getAdapter());
39 | }
40 |
41 | return new MountManager($flies);
42 | });
43 |
44 | $this->app->singleton('flysystem', function ($app) {
45 | return $app->make('flysystem_manager')
46 | ->getFilesystem(config('app.flysystem'));
47 | });
48 | }
49 |
50 | /**
51 | * Get all this service provider provides.
52 | *
53 | * @return array
54 | */
55 | public function provides()
56 | {
57 | return ['flysystem_manager', 'flysystem'];
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Log.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Monolog\Logger;
14 | use Monolog\Handler\StreamHandler;
15 |
16 | /**
17 | * This provider handles the logging, which by default logs the errors, database
18 | * transactions.
19 | */
20 | class Log extends ServiceProvider
21 | {
22 | /**
23 | * {@inheridoc}.
24 | */
25 | public function register()
26 | {
27 | $this->app->singleton('log', function () {
28 | $logger = new Logger('slayer');
29 |
30 | $logger_name = 'slayer';
31 |
32 | if ($ext = logging_extension()) {
33 | $logger_name .= '-'.$ext;
34 | }
35 |
36 | $logger->pushHandler(
37 | new StreamHandler(
38 | storage_path('logs').'/'.$logger_name.'.log',
39 | Logger::DEBUG
40 | )
41 | );
42 |
43 | return $logger;
44 | });
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/ModelManager.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Phalcon\Mvc\Model\Manager;
14 |
15 | /**
16 | * Get the 'modelsManager' service provider.
17 | */
18 | class ModelManager extends ServiceProvider
19 | {
20 | /**
21 | * {@inheridoc}.
22 | */
23 | public function register()
24 | {
25 | $this->app->instance('modelsManager', new Manager, $singleton = true);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/ModelMetadata.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Phalcon\Mvc\Model\Metadata\Memory;
14 |
15 | /**
16 | * This provider is required when querying fields using Phalcon Models.
17 | *
18 | * To speed up development Phalcon\Mvc\Model helps you to query fields and
19 | * constraints from tables related to models. To achieve this,
20 | * Phalcon\Mvc\Model\MetaData is available to manage and cache table meta-data.
21 | */
22 | class ModelMetadata extends ServiceProvider
23 | {
24 | /**
25 | * {@inheridoc}.
26 | */
27 | public function register()
28 | {
29 | $this->app->instance('modelsMetadata', new Memory, $singleton = true);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Module.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | /**
14 | * This provider manage all registered and injected modules.
15 | */
16 | class Module extends ServiceProvider
17 | {
18 | /**
19 | * {@inheridoc}.
20 | */
21 | public function register()
22 | {
23 | $this->app->singleton('module', function () {
24 | return $this;
25 | });
26 | }
27 |
28 | /**
29 | * This sets a batch of modules.
30 | *
31 | * @param mixed $modules
32 | * @return \Clarity\Providers\Module Returns itself
33 | */
34 | public function setModules(array $modules)
35 | {
36 | foreach ($modules as $name => $closure) {
37 | $this->setModule($name, $closure);
38 | }
39 |
40 | return $this;
41 | }
42 |
43 | /**
44 | * This set a single module.
45 | *
46 | * @param string $name
47 | * @param \Closure $closure
48 | * @return \Clarity\Providers\Module Returns itself
49 | */
50 | public function setModule($name, $closure)
51 | {
52 | $modules = [];
53 |
54 | $modules[$name] = $closure;
55 |
56 | config(['modules' => $modules]);
57 |
58 | return $this;
59 | }
60 |
61 | /**
62 | * This returns all the available modules.
63 | *
64 | * Which converted into an array format
65 | *
66 | * @return mixed
67 | */
68 | public function all()
69 | {
70 | if (! isset(config()->modules)) {
71 | return [];
72 | }
73 |
74 | return config()->modules->toArray();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Mongo.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use MongoClient;
14 |
15 | /**
16 | * This provider instantiates the @see \MongoClient.
17 | */
18 | class Mongo extends ServiceProvider
19 | {
20 | /**
21 | * {@inheridoc}.
22 | */
23 | public function register()
24 | {
25 | $this->app->singleton('mongo.selected_adapter', function () {
26 | $adapters = config('database.nosql_adapters');
27 |
28 | $selected_adapter = config()->app->nosql_adapter;
29 |
30 | if (empty($selected_adapter)) {
31 | return false;
32 | }
33 |
34 | if (! isset($adapters[$selected_adapter])) {
35 | return false;
36 | }
37 |
38 | return $adapters[$selected_adapter];
39 | });
40 |
41 | $this->app->singleton('mongo', function ($app) {
42 | if (! class_exists(MongoClient::class)) {
43 | return $this;
44 | }
45 |
46 | $adapter = $app->make('mongo.selected_adapter');
47 |
48 | if (! $adapter) {
49 | return $this;
50 | }
51 |
52 | $host = $adapter->host;
53 | $port = $adapter->port;
54 | $username = $adapter->username;
55 | $password = $adapter->password;
56 |
57 | $str = 'mongodb://'.$username.':'.$password.'@'.$host.':'.$port;
58 |
59 | if (strlen($username) < 1 && strlen($password) < 1) {
60 | $str = 'mongodb://'.$host.':'.$port;
61 | }
62 |
63 | $mongo = new MongoClient($str);
64 |
65 | return $mongo->selectDB($adapter->dbname);
66 | });
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Queue.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Clarity\Support\Queue\Queue as BaseQueue;
14 |
15 | /**
16 | * This provider manages the available queue adapters and creates/instantiate in it.
17 | *
18 | * Activities like processing videos, resizing images or sending emails aren’t
19 | * suitable to be executed online or in real time because it may slow the
20 | * loading time of pages and severely impact the user experience.
21 | */
22 | class Queue extends ServiceProvider
23 | {
24 | /**
25 | * {@inheritdoc}
26 | */
27 | public function register()
28 | {
29 | $this->app->singleton('queue.selected_adapter', function () {
30 | $selected_adapter = config()->app->queue_adapter;
31 |
32 | return config()->queue->{$selected_adapter};
33 | });
34 |
35 | $this->app->singleton('queue', function ($app) {
36 | $adapter = resolve('queue.selected_adapter');
37 |
38 | $class = $adapter->class;
39 | $config = $adapter->config->toArray();
40 |
41 | return new BaseQueue(new $class($config));
42 | });
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Redirect.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Clarity\Support\Redirect\Redirect as BaseRedirect;
14 |
15 | /**
16 | * This provider manages the redirection of a page or dispatched request.
17 | */
18 | class Redirect extends ServiceProvider
19 | {
20 | /**
21 | * {@inheridoc}.
22 | */
23 | public function register()
24 | {
25 | $this->app->instance('redirect', new BaseRedirect, $singleton = true);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Request.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Clarity\Support\Phalcon\Http\Request as BaseRequest;
14 |
15 | /**
16 | * This provider manages the dispatcher requests.
17 | */
18 | class Request extends ServiceProvider
19 | {
20 | /**
21 | * {@inheridoc}.
22 | */
23 | public function register()
24 | {
25 | $this->app->instance('request', new BaseRequest, $singleton = true);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Response.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Phalcon\Http\Response as BaseResponse;
14 |
15 | /**
16 | * This provider manages the response or headers to be passed in.
17 | */
18 | class Response extends ServiceProvider
19 | {
20 | /**
21 | * {@inheridoc}.
22 | */
23 | public function register()
24 | {
25 | $this->app->instance('response', new BaseResponse, $singleton = true);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Router.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Clarity\Support\Phalcon\Mvc\Router as BaseRouter;
14 |
15 | /**
16 | * This provider manages the url routes, which parses and provides a map
17 | * which the dispather could interpret and manages to call controller's action.
18 | */
19 | class Router extends ServiceProvider
20 | {
21 | /**
22 | * {@inheridoc}.
23 | */
24 | public function register()
25 | {
26 | $this->app->singleton('router', function () {
27 | $router = new BaseRouter(false);
28 |
29 | $router->removeExtraSlashes(true);
30 |
31 | // $router->setUriSource(BaseRouter::URI_SOURCE_GET_URL); // default
32 | $router->setUriSource(BaseRouter::URI_SOURCE_SERVER_REQUEST_URI);
33 |
34 | return $router;
35 | });
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/RouterAnnotations.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Phalcon\Mvc\Router\Annotations as BaseRouter;
14 |
15 | /**
16 | * This provider provides an alternative way to create routes by inserting
17 | * annotations inside controller's action.
18 | */
19 | class RouterAnnotations extends ServiceProvider
20 | {
21 | /**
22 | * {@inheridoc}.
23 | */
24 | public function register()
25 | {
26 | $this->app->instance('router_annotations', new BaseRouter, $singleton = true);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Security.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Phalcon\Security as BaseSecurity;
14 |
15 | /**
16 | * Get the 'security' service provider.
17 | */
18 | class Security extends ServiceProvider
19 | {
20 | /**
21 | * {@inheridoc}.
22 | */
23 | public function register()
24 | {
25 | $this->app->instance('security', new BaseSecurity, $singleton = true);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Session.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | /**
14 | * This provider handles the available session adapters, wherein it manages
15 | * the user's activity or browser's unique session id.
16 | */
17 | class Session extends ServiceProvider
18 | {
19 | /**
20 | * {@inheridoc}.
21 | */
22 | public function register()
23 | {
24 | $this->app->singleton('session.selected_adapter', function () {
25 | $selected_adapter = config()->app->session_adapter;
26 |
27 | return config()->session->{$selected_adapter};
28 | });
29 |
30 | $this->app->singleton('session', function ($app) {
31 | $adapter = resolve('session.selected_adapter')->toArray();
32 |
33 | $options = [];
34 | $class = $adapter['class'];
35 |
36 | if (isset($adapter['options'])) {
37 | $options = $adapter['options'];
38 | }
39 |
40 | $session = new $class($options);
41 | $session->setName(config()->app->session);
42 | $session->start();
43 |
44 | return $session;
45 | });
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Tag.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Phalcon\Tag as BaseTag;
14 |
15 | /**
16 | * Get the 'tag' service provider.
17 | */
18 | class Tag extends ServiceProvider
19 | {
20 | /**
21 | * {@inheridoc}.
22 | */
23 | public function register()
24 | {
25 | $this->app->instance('tag', new BaseTag, $singleton = true);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/TransactionManager.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Phalcon\Mvc\Model\Transaction\Manager;
14 |
15 | /**
16 | * Get the 'transactionManager' service provider.
17 | */
18 | class TransactionManager extends ServiceProvider
19 | {
20 | /**
21 | * {@inheridoc}.
22 | */
23 | public function register()
24 | {
25 | $this->app->instance('transactionManager', new Manager, $singleton = true);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/URL.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Clarity\Support\Phalcon\Mvc\URL as BaseURL;
14 |
15 | /**
16 | * This provider instantiates the @see \Clarity\Support\Phalcon\Mvc\URL.
17 | */
18 | class URL extends ServiceProvider
19 | {
20 | /**
21 | * @var bool
22 | */
23 | protected $defer = true;
24 |
25 | /**
26 | * Get all this service provider provides.
27 | *
28 | * @return array
29 | */
30 | public function provides()
31 | {
32 | return ['url'];
33 | }
34 |
35 | /**
36 | * {@inheridoc}.
37 | */
38 | public function boot()
39 | {
40 | $url = resolve('url');
41 | $url->setDI($this->getDI());
42 | $url->setBaseUri($url->getFullUrl().'/');
43 | }
44 |
45 | /**
46 | * {@inheritdoc}
47 | */
48 | public function register()
49 | {
50 | $this->app->singleton('url', function () {
51 | return new BaseURL();
52 | });
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/Validator.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | use Clarity\Util;
14 |
15 | /**
16 | * Get the 'validator' service provider.
17 | */
18 | class Validator extends ServiceProvider
19 | {
20 | /**
21 | * {@inheridoc}.
22 | */
23 | public function register()
24 | {
25 | $this->app->instance('validator', new Util\Validator\Validator, $singleton = true);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Providers/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "clarity/providers",
3 | "description": "",
4 | "license": "MIT",
5 | "homepage": "http://github.com/ps-clarity/providers",
6 | "support": {
7 | "issues": "https://github.com/ps-clarity/providers/issues",
8 | "source": "https://github.com/ps-clarity/providers"
9 | },
10 | "authors": [
11 | {
12 | "name": "Daison Carino",
13 | "email": "daison12006013@gmail.com"
14 | }
15 | ],
16 | "autoload": {
17 | "psr-4": {
18 | "Clarity\\Providers\\": ""
19 | }
20 | },
21 | "extra": {
22 | "branch-alias": {
23 | "dev-master": "1.4-dev"
24 | }
25 | },
26 | "minimum-stability": "dev"
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Services/ServiceMagicMethods.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Services;
12 |
13 | use InvalidArgumentException;
14 |
15 | trait ServiceMagicMethods
16 | {
17 | public function __get($name)
18 | {
19 | if (di()->has($name) === false) {
20 | throw new InvalidArgumentException("Dependency Injection [$name] not found");
21 | }
22 |
23 | return di()->get($name);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Clarity/Services/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "clarity/services",
3 | "description": "",
4 | "license": "MIT",
5 | "homepage": "http://github.com/ps-clarity/services",
6 | "support": {
7 | "issues": "https://github.com/ps-clarity/services/issues",
8 | "source": "https://github.com/ps-clarity/services"
9 | },
10 | "authors": [
11 | {
12 | "name": "Daison Carino",
13 | "email": "daison12006013@gmail.com"
14 | }
15 | ],
16 | "autoload": {
17 | "psr-4": {
18 | "Clarity\\Services\\": ""
19 | }
20 | },
21 | "extra": {
22 | "branch-alias": {
23 | "dev-master": "1.4-dev"
24 | }
25 | },
26 | "minimum-stability": "dev"
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Curl/README.md:
--------------------------------------------------------------------------------
1 | # cURL layer
2 |
3 |
4 | ```php
5 | $base_uri = 'http://slayer.app';
6 | $client = (new RESTful($base_uri))->getClient();
7 | ```
8 | The code above returns the Guzzle client, this is used under ``request(...)->module(...)``
9 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Curl/RESTful.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Support\Curl;
12 |
13 | use GuzzleHttp\Client;
14 |
15 | /**
16 | * A basic restful request.
17 | */
18 | class RESTful
19 | {
20 | /**
21 | * @var mixed|\GuzzleHttp\Client
22 | */
23 | private $client;
24 |
25 | /**
26 | * Contructor.
27 | *
28 | * @param string $base_uri
29 | */
30 | public function __construct($base_uri)
31 | {
32 | $this->client = new Client([
33 | 'base_uri' => $base_uri,
34 | ]);
35 | }
36 |
37 | /**
38 | * Get the client.
39 | *
40 | * @return mixed|\GuzzleHttp\Client
41 | */
42 | public function getClient()
43 | {
44 | return $this->client;
45 | }
46 |
47 | /**
48 | * Callable.
49 | *
50 | * @param string $method
51 | * @param array $params
52 | */
53 | public function __call($method, $params)
54 | {
55 | return call_user_func_array([$this->client, $method], $params);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/Clarity/Support/DB/Factory.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Support\DB;
12 |
13 | use Faker\Factory as FakerFactory;
14 |
15 | /**
16 | * The database seeder factory.
17 | */
18 | class Factory
19 | {
20 | /**
21 | * @var mixed|\Faker\Factory
22 | */
23 | private $seed_factory;
24 |
25 | /**
26 | * Contructor.
27 | *
28 | * @param mixed|\Faker\Factory $seed_factory
29 | */
30 | public function __construct($seed_factory)
31 | {
32 | $this->seed_factory = $seed_factory;
33 | }
34 |
35 | /**
36 | * Define a factory.
37 | *
38 | * @param string $class
39 | * @param mixed|\Closure $callback
40 | * @param int $loop
41 | */
42 | public function define($class, $callback, $loop = 1)
43 | {
44 | for ($i = 1; $i <= $loop; $i++) {
45 | $data = call_user_func($callback, FakerFactory::create());
46 | $instance = new $class;
47 | $instance->create($data);
48 |
49 | $this->seed_factory->comment("\nLoop #".$i.": \n ".json_encode($data)."\n");
50 | }
51 |
52 | return $this;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Helpers/init.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | /**
12 | * This calls the sub-files.
13 | */
14 | require __DIR__.'/slayer.php';
15 | require __DIR__.'/paths.php';
16 | require __DIR__.'/misc.php';
17 | require __DIR__.'/facade.php';
18 | require __DIR__.'/url.php';
19 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Helpers/slayer.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 | if (! function_exists('di')) {
11 |
12 | /**
13 | * This calls our default dependency injection.
14 | *
15 | * @param string|mixed $alias The service provider alias
16 | * @return Phalcon\Di|mixed
17 | */
18 | function di($alias = null)
19 | {
20 | $default = Clarity\Support\Phalcon\Di::getDefault();
21 |
22 | if (is_string($alias)) {
23 | return $default->get($alias);
24 | }
25 |
26 | # if the alias is array then we must check the array
27 | # passed in
28 | if (is_array($alias)) {
29 | if (
30 | ! isset($alias[0]) ||
31 | ! isset($alias[1])
32 | ) {
33 | throw new InvalidArgumentException('Provider alias or callback not found');
34 | }
35 |
36 | $default->set(
37 | $alias[0],
38 | $alias[1],
39 | isset($alias[2]) ? $alias[2] : false
40 | );
41 |
42 | return $default->get($alias[0]);
43 | }
44 |
45 | # or just return the default thing
46 | return $default;
47 | }
48 | }
49 |
50 | if (! function_exists('resolve')) {
51 |
52 | /**
53 | * Resolve a service provider.
54 | *
55 | * @param string $alias
56 | * @return [type]
57 | */
58 | function resolve($alias = null)
59 | {
60 | if (di()->has($alias)) {
61 | return di()->get($alias);
62 | }
63 |
64 | \Clarity\Services\Mapper::resolveBinding(di(), $alias);
65 |
66 | return di()->get($alias);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Helpers/url.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 | if (! function_exists('base_uri')) {
11 |
12 | /**
13 | * This returns the base uri of the current module, if passed an argument
14 | * it automatically appended as uri.
15 | *
16 | * @param $extend_path To provide uri
17 | * @return string
18 | */
19 | function base_uri($extend_path = null)
20 | {
21 | if (is_cli()) {
22 | return;
23 | }
24 |
25 | $url = url()->getHost();
26 | $scheme = url()->getScheme();
27 |
28 | return url_trimmer($scheme.'/'.$url.'/'.$extend_path);
29 | }
30 | }
31 |
32 | if (! function_exists('back')) {
33 |
34 | /**
35 | * This returns the previous request url.
36 | *
37 | * @return string
38 | */
39 | function back()
40 | {
41 | return di()->get('url')->previous();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Phalcon/Di.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Support\Phalcon;
12 |
13 | use Phalcon\Di as BaseDi;
14 |
15 | /**
16 | * Override the existing Phalcon\DI class.
17 | */
18 | class Di extends BaseDi implements \Phalcon\DiInterface
19 | {
20 | /**
21 | * {@inheritdoc}
22 | */
23 | public function get($name, $parameters = null)
24 | {
25 | try {
26 | return parent::get($name, $parameters);
27 | } catch (\Phalcon\Di\Exception $e) {
28 | return resolve($name);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Phalcon/Events/Manager.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Support\Phalcon\Events;
12 |
13 | use Phalcon\Events\Manager as BaseManager;
14 |
15 | /**
16 | * {@inheritdoc}
17 | */
18 | class Manager extends BaseManager
19 | {
20 | }
21 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Phalcon/Http/Middleware.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Support\Phalcon\Http;
12 |
13 | use InvalidArgumentException;
14 |
15 | /**
16 | * {@inheritdoc}
17 | */
18 | class Middleware
19 | {
20 | /**
21 | * @var array
22 | */
23 | protected $middlewares = [];
24 |
25 | /**
26 | * Contructor.
27 | *
28 | * @param array $middlewares
29 | */
30 | public function __construct($middlewares = [])
31 | {
32 | $this->middlewares = $middlewares;
33 | }
34 |
35 | /**
36 | * Get a middleware.
37 | *
38 | * @param string $alias
39 | * @return string
40 | */
41 | public function get($alias)
42 | {
43 | if (! isset($this->middlewares[$alias])) {
44 | throw new InvalidArgumentException(
45 | "Middleware based on alias [$alias] not found."
46 | );
47 | }
48 |
49 | return $this->middlewares[$alias];
50 | }
51 |
52 | /**
53 | * Set a middleware.
54 | *
55 | * @param array $middlewares
56 | * @return mixed|\Clarity\Support\Phalcon\Http\Middleware
57 | */
58 | public function set($middlewares)
59 | {
60 | $this->middlewares = $middlewares;
61 |
62 | return $this;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Phalcon/Http/Request.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Support\Phalcon\Http;
12 |
13 | use Clarity\Support\Curl\RESTful;
14 | use Phalcon\Http\Request as BaseRequest;
15 |
16 | /**
17 | * {@inheritdoc}
18 | */
19 | class Request extends BaseRequest
20 | {
21 | /**
22 | * Request based on a initialized module.
23 | *
24 | * @param string $name
25 | * @return mixed|\Clarity\Support\Curl\RESTful
26 | */
27 | public function module($name)
28 | {
29 | return new RESTful(url()->getFullUrl($name));
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Phalcon/Mvc/Application.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Support\Phalcon\Mvc;
12 |
13 | use Phalcon\Mvc\Application as BaseApplication;
14 |
15 | /**
16 | * {@inheritdoc}
17 | */
18 | class Application extends BaseApplication
19 | {
20 | }
21 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Phalcon/Mvc/Collection.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Support\Phalcon\Mvc;
12 |
13 | use Phalcon\Mvc\Collection as BaseCollection;
14 |
15 | /**
16 | * {@inheritdoc}
17 | */
18 | class Collection extends BaseCollection
19 | {
20 | /**
21 | * A shortcut way when creating a new document.
22 | *
23 | * @param array $data
24 | * @return bool
25 | */
26 | public function create($data)
27 | {
28 | foreach ($data as $key => $val) {
29 | $this->{$key} = $val;
30 | }
31 |
32 | return $this->save();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Phalcon/Mvc/Controller.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Support\Phalcon\Mvc;
12 |
13 | use Phalcon\Config;
14 | use League\Tactician\CommandBus;
15 | use Clarity\Support\Phalcon\Http\Middleware;
16 | use Phalcon\Mvc\Controller as BaseController;
17 |
18 | /**
19 | * @method initMiddleware() initialize middlewares in top-level controller
20 | */
21 | class Controller extends BaseController
22 | {
23 | /**
24 | * {@inheritdoc}
25 | */
26 | public function beforeExecuteRoute()
27 | {
28 | # call the initialize to work with the middleware()
29 | if (method_exists($this, 'initMiddleware')) {
30 | $this->initMiddleware();
31 | }
32 |
33 | $this->middlewareHandler();
34 | }
35 |
36 | /**
37 | * {@inheritdoc}
38 | */
39 | protected function middleware($alias, $options = [])
40 | {
41 | $middlewares = [];
42 |
43 | # get previously assigned aliases
44 | if ($this->getDI()->has('middleware_aliases')) {
45 | $middlewares = $this->getDI()->get('middleware_aliases')->toArray();
46 | }
47 |
48 | $append_alias = true;
49 | $action_name = dispatcher()->getActionName();
50 |
51 | if (isset($options['only'])) {
52 | if (in_array($action_name, $options['only']) === false) {
53 | $append_alias = false;
54 | }
55 | }
56 |
57 | if (isset($options['except'])) {
58 | if (in_array($action_name, $options['except'])) {
59 | $append_alias = false;
60 | }
61 | }
62 |
63 | if ($append_alias === true) {
64 | $middlewares[] = $alias;
65 | }
66 |
67 | $this->getDI()->set('middleware_aliases', function () use ($middlewares) {
68 | return new Config($middlewares);
69 | });
70 | }
71 |
72 | /**
73 | * Handle the registered middlewares in the controller.
74 | *
75 | * @return void
76 | */
77 | private function middlewareHandler()
78 | {
79 | if ($this->getDI()->has('middleware_aliases') === false) {
80 | return;
81 | }
82 |
83 | # get all the middlewares in the config/app.php
84 | $middleware = new Middleware(config()->app->middlewares);
85 |
86 | $instances = [];
87 | $aliases = $this->getDI()->get('middleware_aliases')->toArray();
88 |
89 | foreach ($aliases as $alias) {
90 | $class = $middleware->get($alias);
91 | $instances[] = new $class;
92 | }
93 |
94 | # register all the middlewares
95 | $command_bus = new CommandBus($instances);
96 | $command_bus->handle($this->request);
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Phalcon/Mvc/Dispatcher.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Support\Phalcon\Mvc;
12 |
13 | use Phalcon\Mvc\Dispatcher as BaseDispatcher;
14 |
15 | /**
16 | * {@inheritdoc}
17 | */
18 | class Dispatcher extends BaseDispatcher
19 | {
20 | /**
21 | * Get controller suffix.
22 | *
23 | * @return string
24 | */
25 | public function getControllerSuffix()
26 | {
27 | return $this->_handlerSuffix;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Phalcon/Mvc/Router.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Support\Phalcon\Mvc;
12 |
13 | use Phalcon\Mvc\Router as BaseRouter;
14 |
15 | /**
16 | * {@inheritdoc}
17 | */
18 | class Router extends BaseRouter
19 | {
20 | /**
21 | * Contructor.
22 | *
23 | * @param bool $bool
24 | */
25 | public function __construct($bool)
26 | {
27 | parent::__construct($bool);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Phinx/Db/Table.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Support\Phinx\Db;
12 |
13 | use Phinx\Db\Table as PhinxTable;
14 |
15 | /**
16 | * {@inheritdoc}
17 | */
18 | class Table extends PhinxTable
19 | {
20 | /**
21 | * {@inheritdoc}
22 | */
23 | public function addSoftDeletes()
24 | {
25 | $this
26 | ->addColumn('deleted_at', 'timestamp', [
27 | 'null' => true,
28 | ]);
29 |
30 | return $this;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Phinx/Migration/AbstractMigration.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Support\Phinx\Migration;
12 |
13 | use Clarity\Support\Phinx\Db\Table;
14 | use Phinx\Migration\AbstractMigration as BaseAbstractMigration;
15 |
16 | /**
17 | * This class extends the package @see robmorgan\phinx AbstractMigration.
18 | *
19 | * We extended this to wrap the parent class, this will be used for future
20 | * modifications if needed, while the stub generated when calling db:migrate
21 | * through brood, extends this class as well.
22 | */
23 | abstract class AbstractMigration extends BaseAbstractMigration
24 | {
25 | /**
26 | * {@inheritdoc}
27 | *
28 | * @param string $table_name The table name to be created/updated
29 | * @param mixed $options The options when migrating a tabke
30 | * @return \Clarity\Support\Phinx\Db\Table
31 | */
32 | public function table($table_name, $options = [])
33 | {
34 | return new Table($table_name, $options, $this->getAdapter());
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Phinx/Seed/AbstractSeed.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Support\Phinx\Seed;
12 |
13 | use Phinx\Seed\AbstractSeed as BaseAbstractSeed;
14 |
15 | /**
16 | * {@inheritdoc}
17 | */
18 | class AbstractSeed extends BaseAbstractSeed
19 | {
20 | }
21 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Queue/Beanstalkd/Beanstalkd.php:
--------------------------------------------------------------------------------
1 | config = $config;
31 | $this->instance = new BaseBeanstalk($config);
32 | }
33 |
34 | /**
35 | * Callable.
36 | *
37 | * @param string $func
38 | * @param array $params
39 | */
40 | public function __call($func, $params)
41 | {
42 | return call_user_func_array([$this->instance, $func], $params);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Queue/DriverInterface.php:
--------------------------------------------------------------------------------
1 | adapter = $adapter;
23 | }
24 |
25 | /**
26 | * Callable.
27 | *
28 | * @param string $func
29 | * @param array $params
30 | */
31 | public function __call($func, $params)
32 | {
33 | return call_user_func_array([$this->adapter, $func], $params);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Clarity/Support/Redirect/Redirect.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Support\Redirect;
12 |
13 | use Clarity\Support\WithMagicMethodTrait;
14 |
15 | /***
16 | * Class Redirect
17 | * @package Clarity\Support\Redirect
18 | *
19 | * @method withError(string $message) write error flash message
20 | * @method withSuccess(string $message) write success flash message
21 | */
22 | class Redirect
23 | {
24 | use WithMagicMethodTrait;
25 |
26 | /**
27 | * Redirect based on the provided url.
28 | *
29 | * @param string $url
30 | * @return mixed|\Clarity\Support\Redirect\Redirect
31 | */
32 | public function to($url)
33 | {
34 | resolve('response')->redirect($url);
35 |
36 | return $this;
37 | }
38 |
39 | /**
40 | * Passing a query param.
41 | *
42 | * @param string $key
43 | * @param string $value
44 | * @return mixed|\Clarity\Support\Redirect\Redirect
45 | */
46 | public function with($key, $value)
47 | {
48 | resolve('flash')->session()->message($key, $value);
49 |
50 | return $this;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/Clarity/Support/WithMagicMethodTrait.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Support;
12 |
13 | use BadMethodCallException;
14 |
15 | trait WithMagicMethodTrait
16 | {
17 | /**
18 | * Magic methods that uses 'withVarName'.
19 | *
20 | * @return string
21 | */
22 | public function __call($method, $parameters)
23 | {
24 | if (starts_with($method, 'with')) {
25 | return $this->with(snake_case(substr($method, 4)),
26 | $parameters[ 0 ]);
27 | }
28 |
29 | throw new BadMethodCallException("Method [$method] does not exist on view.");
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Clarity/Support/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "clarity/support",
3 | "description": "",
4 | "license": "MIT",
5 | "homepage": "http://github.com/ps-clarity/support",
6 | "support": {
7 | "issues": "https://github.com/ps-clarity/support/issues",
8 | "source": "https://github.com/ps-clarity/support"
9 | },
10 | "authors": [
11 | {
12 | "name": "Daison Carino",
13 | "email": "daison12006013@gmail.com"
14 | }
15 | ],
16 | "require": {
17 | "illuminate/support": "5.4.*",
18 | "fzaninotto/faker": "~1.4",
19 | "league/tactician": "^0.6",
20 | "paragonie/random_compat": "~1.4|~2.0",
21 | "clarity/contracts": "1.4.*",
22 | "clarity/exceptions": "1.4.*",
23 | "robmorgan/phinx": "0.6.*"
24 | },
25 | "autoload": {
26 | "psr-4": {
27 | "Clarity\\Support\\": ""
28 | },
29 | "files": [
30 | "Helpers/init.php"
31 | ]
32 | },
33 | "extra": {
34 | "branch-alias": {
35 | "dev-master": "1.4-dev"
36 | }
37 | },
38 | "minimum-stability": "dev"
39 | }
40 |
--------------------------------------------------------------------------------
/src/Clarity/TestSuite/Behat/Mink/Adapters/DriverInterface.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\TestSuite\Behat\Mink\Adapters;
12 |
13 | /**
14 | * A driver contract for behat mink.
15 | */
16 | interface DriverInterface
17 | {
18 | /**
19 | * Constructor.
20 | *
21 | * @param array $args
22 | */
23 | public function __construct($args);
24 |
25 | /**
26 | * Get the driver.
27 | *
28 | * @return mixed
29 | */
30 | public function driver();
31 | }
32 |
--------------------------------------------------------------------------------
/src/Clarity/TestSuite/Behat/Mink/Adapters/Goutte.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\TestSuite\Behat\Mink\Adapters;
12 |
13 | use ReflectionClass;
14 | use Behat\Mink\Driver\GoutteDriver;
15 |
16 | /**
17 | * The goutte driver for behat mink.
18 | */
19 | class Goutte implements DriverInterface
20 | {
21 | /**
22 | * @var mixe|\Behat\Mink\Driver\GoutteDriver
23 | */
24 | private $driver;
25 |
26 | /**
27 | * {@inheritdoc}
28 | */
29 | public function __construct($args)
30 | {
31 | $reflect = new ReflectionClass(GoutteDriver::class);
32 | $this->driver = $reflect->newInstanceArgs($args);
33 | }
34 |
35 | /**
36 | * Get the driver.
37 | *
38 | * @return mixed|\Behat\Mink\Driver\GoutteDriver
39 | */
40 | public function driver()
41 | {
42 | return $this->driver;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/Clarity/TestSuite/Behat/Mink/Mink.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\TestSuite\Behat\Mink;
12 |
13 | use Behat\Mink\Session;
14 | use InvalidArgumentException;
15 |
16 | /**
17 | * The Behat Mink Handler.
18 | */
19 | class Mink
20 | {
21 | /**
22 | * @var mixed
23 | */
24 | private $driver;
25 |
26 | /**
27 | * @var mixed
28 | */
29 | private $session;
30 |
31 | /**
32 | * @var array
33 | */
34 | private $adapters;
35 |
36 | /**
37 | * Constructor.
38 | *
39 | * @param array $adapters
40 | */
41 | public function __construct($adapters = [])
42 | {
43 | $this->setAdapters($adapters);
44 | }
45 |
46 | /**
47 | * Set the adapters.
48 | *
49 | * @param array $adapters
50 | * @return mixed|\Clarity\TestSuite\Behat\Mink\Mink
51 | */
52 | public function setAdapters(array $adapters)
53 | {
54 | if (empty($adapters)) {
55 | $adapters = require __DIR__.'/config.php';
56 | }
57 |
58 | $this->adapters = $adapters;
59 |
60 | return $this;
61 | }
62 |
63 | /**
64 | * Get an adapter.
65 | *
66 | * @param string $name
67 | * @return mixed|\Behat\Mink\Session
68 | */
69 | public function get($name)
70 | {
71 | if (! isset($this->adapters[$name])) {
72 | throw new InvalidArgumentException("Adapter [$name] not found.");
73 | }
74 |
75 | $adapter = $this->adapters[$name];
76 |
77 | $class = $adapter['class'];
78 | $args = $adapter['args'];
79 |
80 | $instance = new $class($args);
81 |
82 | return new Session($instance->driver());
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/Clarity/TestSuite/Behat/Mink/config.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 | use \Clarity\TestSuite\Behat\Mink\Adapters;
11 |
12 | return [
13 | 'goutte' => [
14 | 'class' => Clarity\TestSuite\Behat\Mink\Adapters\Goutte::class,
15 | 'args' => [],
16 | ],
17 |
18 | // 'browserkit' => [
19 | // 'class' => Adapters\BrowserKit::class,
20 | // 'args' => [],
21 | // ],
22 |
23 | // 'selenium2' => [
24 | // 'class' => Adapters\Selenium2::class,
25 | // 'args' => ['firefox'],
26 | // ],
27 |
28 | // 'zombie' => [
29 | // 'class' => Adapters\Zombie::class,
30 | // 'args' => [
31 | // new \Behat\Mink\Driver\NodeJS\Server\ZombieServer(
32 | // // $host,
33 | // // $port,
34 | // // $nodeBin,
35 | // // $script
36 | // )
37 | // ],
38 |
39 | // ],
40 |
41 | // 'sahi' => [
42 | // 'class' => Adapters\Sahi::class,
43 | // 'args' => ['firefox'],
44 | // ],
45 | ];
46 |
--------------------------------------------------------------------------------
/src/Clarity/TestSuite/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "clarity/test-suite",
3 | "description": "",
4 | "license": "MIT",
5 | "homepage": "http://github.com/ps-clarity/test-suite",
6 | "support": {
7 | "issues": "https://github.com/ps-clarity/test-suite/issues",
8 | "source": "https://github.com/ps-clarity/test-suite"
9 | },
10 | "authors": [
11 | {
12 | "name": "Daison Carino",
13 | "email": "daison12006013@gmail.com"
14 | }
15 | ],
16 | "require": {
17 | "behat/mink": "^1.7"
18 | },
19 | "autoload": {
20 | "psr-4": {
21 | "Clarity\\TestSuite\\": ""
22 | }
23 | },
24 | "extra": {
25 | "branch-alias": {
26 | "dev-master": "1.4-dev"
27 | }
28 | },
29 | "minimum-stability": "dev"
30 | }
31 |
--------------------------------------------------------------------------------
/src/Clarity/Util/Benchmark/Benchmark.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Util\Benchmark;
12 |
13 | /**
14 | * A simple benchmarking class.
15 | */
16 | class Benchmark
17 | {
18 | /**
19 | * @var float
20 | */
21 | private $start_time;
22 |
23 | /**
24 | * @var array
25 | */
26 | private $markings = [];
27 |
28 | /**
29 | * The constructor.
30 | *
31 | * @param float $start_time
32 | */
33 | public function __construct($start_time)
34 | {
35 | $this->start_time = $start_time;
36 | }
37 |
38 | /**
39 | * Do some calculations.
40 | *
41 | * @param string $name
42 | * @return void
43 | */
44 | public function here($name)
45 | {
46 | # get the current microtime in sec
47 | $now = microtime(true);
48 |
49 | # do some markings
50 | $this->markings[$name] = $this->format($now - $this->start_time);
51 |
52 | # refresh the start time
53 | $this->start_time = $now;
54 |
55 | return $this;
56 | }
57 |
58 | /**
59 | * Format the value into numeric without having E-#.
60 | *
61 | * @param float $value
62 | * @return float
63 | */
64 | protected function format($value)
65 | {
66 | return number_format($value, 12, '.', '');
67 | }
68 |
69 | /**
70 | * Get the markings.
71 | *
72 | * @return array
73 | */
74 | public function get()
75 | {
76 | return $this->markings;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/Clarity/Util/Benchmark/BenchmarkServiceProvider.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Util\Benchmark;
12 |
13 | use Clarity\Providers\ServiceProvider;
14 |
15 | /**
16 | * This provider manages all class aliases.
17 | */
18 | class BenchmarkServiceProvider extends ServiceProvider
19 | {
20 | /**
21 | * @var bool
22 | */
23 | protected $defer = true;
24 |
25 | /**
26 | * Get service provider's provides.
27 | *
28 | * @return array
29 | */
30 | public function provides()
31 | {
32 | return ['benchmark'];
33 | }
34 |
35 | /**
36 | * {@inheridoc}.
37 | */
38 | public function register()
39 | {
40 | $this->app->singleton('benchmark', function () {
41 | return new Benchmark(SLAYER_START);
42 | });
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/Clarity/Util/Composer/Builder.php:
--------------------------------------------------------------------------------
1 | config = json_decode($config, true);
28 |
29 | return $this;
30 | }
31 |
32 | /**
33 | * This overwrite/create a new key-value.
34 | *
35 | * @param string $key
36 | * @param int|string|bool|mixed $value
37 | */
38 | public function set($key, $value)
39 | {
40 | $this->config[$key] = $value;
41 |
42 | return $this;
43 | }
44 |
45 | /**
46 | * This merges an existing key.
47 | *
48 | * @param string $key The key to use
49 | * @param array $value Array value to be merged
50 | * @return \Clarity\Util\Composer\Builder
51 | */
52 | public function merge($key, array $value)
53 | {
54 | $this->config[$key] = array_merge_recursive(
55 | $this->config[$key],
56 | $value
57 | );
58 |
59 | return $this;
60 | }
61 |
62 | /**
63 | * This compile the config.
64 | *
65 | * @param int $format Will be used for 2nd arg in json_encode
66 | * @return string The final composer content
67 | */
68 | public function render($format = JSON_PRETTY_PRINT)
69 | {
70 | return str_replace(
71 | '\/',
72 | '/',
73 | json_encode($this->config, $format)
74 | );
75 | }
76 |
77 | /**
78 | * Return the raw config.
79 | *
80 | * @return mixed Array of config
81 | */
82 | public function toArray()
83 | {
84 | return $this->config;
85 | }
86 |
87 | /**
88 | * Validate config.
89 | *
90 | * @param int $check_all
91 | * @return mixed
92 | */
93 | public function validate($check_all = ValidatingArrayLoader::CHECK_ALL)
94 | {
95 | $tmpfile = tmpfile();
96 | fwrite($tmpfile, $this->render());
97 | fseek($tmpfile, 0);
98 | $metadata = stream_get_meta_data($tmpfile);
99 |
100 | $validator = new ConfigValidator(new NullIO);
101 | list($errors, $publish_errors, $warnings) = $validator->validate($metadata['uri'], $check_all);
102 |
103 | fclose($tmpfile);
104 |
105 | if (! empty($errors)) {
106 | return [
107 | 'valid' => false,
108 | 'errors' => $errors,
109 | ];
110 | }
111 |
112 | if (! empty($publish_errors)) {
113 | return [
114 | 'valid' => false,
115 | 'errors' => $publish_errors,
116 | ];
117 | }
118 |
119 | return [
120 | 'valid' => true,
121 | 'warnings' => $warnings,
122 | ];
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/src/Clarity/Util/Composer/TestConsole.php:
--------------------------------------------------------------------------------
1 | config(
27 | file_get_contents(base_path('composer.json'))
28 | );
29 |
30 | $builder->set('name', 'phalconslayer/slayer');
31 | $builder->merge('require', [
32 | 'phalconslayer/framework' => '1.4.*',
33 | ]);
34 |
35 | $validation = $builder->validate();
36 |
37 | if (! $validation['valid']) {
38 | if (isset($validation['publish_error'])) {
39 | throw new \Exception('Publish Error found '.json_encode($validation['publish_error']));
40 | }
41 |
42 | if (isset($validation['error'])) {
43 | throw new \Exception('Error found '.json_encode($validation['error']));
44 | }
45 | }
46 |
47 | file_put_contents(base_path('composer.json'), $builder->render());
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/Clarity/Util/Validator/Mapper.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Util\Validator;
12 |
13 | use Illuminate\Support\Str;
14 |
15 | /**
16 | * This maps all the available rules and creates a map to get the extracted
17 | * methods and parameters.
18 | */
19 | class Mapper
20 | {
21 | /**
22 | * @var array
23 | */
24 | private $rules;
25 |
26 | /**
27 | * Set the rules.
28 | *
29 | * @param array $rules
30 | * @return \Clarity\Util\Validator\Mapper
31 | */
32 | public function setRules($rules)
33 | {
34 | $this->rules = $rules;
35 |
36 | return $this;
37 | }
38 |
39 | /**
40 | * Handle the rule sequence builder.
41 | *
42 | * @param array $explicit_rules
43 | * @param bool $merge
44 | * @return array
45 | */
46 | public function handle($explicit_rules = [], $merge = false)
47 | {
48 | $rules = $this->rules;
49 |
50 | # you could pass a custom rules to override the existing provided rules.
51 | # yet you could specify to merge or not.
52 | if (count($explicit_rules) > 0) {
53 | if ($merge) {
54 | $rules = array_merge($rules, $explicit_rules);
55 | } else {
56 | $rules = $explicit_rules;
57 | }
58 | }
59 |
60 | return $this->parse($this->rules);
61 | }
62 |
63 | /**
64 | * Parse the rules into well formed array.
65 | *
66 | * @param array $rules
67 | * @return array
68 | */
69 | public function parse($rules)
70 | {
71 | $maps = [];
72 |
73 | foreach ($rules as $field => $rule) {
74 | if (is_string($rule)) {
75 | $rule = [$rule];
76 | }
77 |
78 | foreach ($rule as $key => $val) {
79 | $must_be = true;
80 | $method = $val;
81 | $params = [];
82 |
83 | # check if the key is string, then that's an associative
84 | # array to parse the remaining method and params.
85 | if (is_string($key)) {
86 | $method = $key;
87 | $params = $rule[$key];
88 | }
89 |
90 | # check weither the method has exclamation point
91 | # that means we need to reverse the expected value by
92 | # changing the $must_be to false
93 | if ($method{0} === '!') {
94 | $must_be = false;
95 | $method = substr($method, 1);
96 | }
97 |
98 | $maps[] = [
99 | 'field' => $field,
100 | 'must_be' => $must_be,
101 | 'method' => lcfirst(Str::studly($method)),
102 | 'params' => $params,
103 | ];
104 | }
105 | }
106 |
107 | return $maps;
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/src/Clarity/Util/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "clarity/util",
3 | "description": "",
4 | "license": "MIT",
5 | "homepage": "http://github.com/ps-clarity/util",
6 | "support": {
7 | "issues": "https://github.com/ps-clarity/util/issues",
8 | "source": "https://github.com/ps-clarity/util"
9 | },
10 | "authors": [
11 | {
12 | "name": "Daison Carino",
13 | "email": "daison12006013@gmail.com"
14 | }
15 | ],
16 | "autoload": {
17 | "psr-4": {
18 | "Clarity\\Util\\": ""
19 | }
20 | },
21 | "extra": {
22 | "branch-alias": {
23 | "dev-master": "1.4-dev"
24 | }
25 | },
26 | "minimum-stability": "dev"
27 | }
28 |
--------------------------------------------------------------------------------
/src/Clarity/View/Blade/BladeAdapter.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\View\Blade;
12 |
13 | use Phalcon\DiInterface;
14 | use Jenssegers\Blade\Blade;
15 | use Phalcon\Mvc\View\Engine;
16 | use Phalcon\Mvc\ViewBaseInterface;
17 | use Phalcon\Mvc\View\EngineInterface;
18 |
19 | /**
20 | * The blade adapter for View Templating/Engine.
21 | */
22 | class BladeAdapter extends Engine implements EngineInterface
23 | {
24 | /**
25 | * @var mixed
26 | */
27 | private $blade;
28 |
29 | /**
30 | * Contructor.
31 | *
32 | * @param mixed|\Phalcon\Mvc\ViewBaseInterface $view
33 | * @param mixed|\Phalcon\DiInterface $di
34 | */
35 | public function __construct(ViewBaseInterface $view, DiInterface $di = null)
36 | {
37 | parent::__construct($view, $di);
38 |
39 | $this->blade = new Blade(
40 | $this->getView()->getViewsDir(),
41 | storage_path('views').'/'
42 | );
43 | }
44 |
45 | /**
46 | * Build the path based on the provided string.
47 | *
48 | * @param string $path
49 | * @return string
50 | */
51 | private function buildPath($path)
52 | {
53 | $path = str_replace($this->getView()->getViewsDir(), '', $path);
54 | $path = str_replace('.blade.php', '', $path);
55 |
56 | return $path;
57 | }
58 |
59 | /**
60 | * Get the blade instance.
61 | *
62 | * @return mixed|\Jenssegers\Blade\Blade
63 | */
64 | protected function getBlade()
65 | {
66 | return $this->blade;
67 | }
68 |
69 | /**
70 | * Get the blade instance in static way.
71 | *
72 | * @return mixed|\Jenssegers\Blade\Blade
73 | */
74 | public static function blade()
75 | {
76 | return (new static)->getBlade();
77 | }
78 |
79 | /**
80 | * Render the path provided.
81 | *
82 | * @param string $path
83 | * @param array $params
84 | * @param bool $must_clean
85 | * @return void
86 | */
87 | public function render($path, $params, $must_clean = null)
88 | {
89 | $content = $this->getBlade()
90 | ->make($this->buildPath($path), $params)
91 | ->render();
92 |
93 | if ($must_clean) {
94 | $this->_view->setContent($content);
95 | } else {
96 | echo $content;
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/src/Clarity/View/ViewServiceProvider.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\View;
12 |
13 | use Phalcon\Events\Event;
14 | use Phalcon\Mvc\View\Engine\Php;
15 | use Clarity\View\Volt\VoltAdapter;
16 | use Clarity\View\Blade\BladeAdapter;
17 | use Clarity\Support\Phalcon\Mvc\View;
18 | use Clarity\Providers\ServiceProvider;
19 |
20 | /**
21 | * The 'view' service provider.
22 | */
23 | class ViewServiceProvider extends ServiceProvider
24 | {
25 | /**
26 | * {@inheritdoc}
27 | */
28 | public function boot()
29 | {
30 | $this->app->singleton('view.event_manager', function ($app) {
31 | $event_manager = $app->make('eventsManager');
32 |
33 | $event_manager->attach('view:afterRender',
34 | function (
35 | Event $event,
36 | View $dispatcher,
37 | $exception
38 | ) {
39 | $dispatcher->getDI()->get('flash')->session()->clear();
40 | }
41 | );
42 |
43 | $app->make('view')->setEventsManager($event_manager);
44 | });
45 | }
46 |
47 | /**
48 | * {@inheritdoc}
49 | */
50 | public function register()
51 | {
52 | $this->app->singleton('view', function () {
53 | $view = new View;
54 |
55 | $view->setViewsDir(config()->path->views);
56 |
57 | $view->registerEngines([
58 | '.phtml' => Php::class,
59 | '.volt' => VoltAdapter::class,
60 | '.blade.php' => BladeAdapter::class,
61 | ]);
62 |
63 | return $view;
64 | });
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/Clarity/View/Volt/VoltAdapter.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\View\Volt;
12 |
13 | use Phalcon\DiInterface;
14 | use Phalcon\Mvc\View\Engine\Volt;
15 | use Phalcon\Mvc\ViewBaseInterface;
16 |
17 | /**
18 | * The 'volt' adapter for View Teamplate/Engine.
19 | */
20 | class VoltAdapter extends Volt
21 | {
22 | /**
23 | * @var array
24 | */
25 | private $functions = [
26 | # misc
27 | 'di', 'env', 'csrf_field',
28 | 'dd', 'config',
29 |
30 | # facades
31 | 'auth', 'cache', 'config',
32 | 'db', 'filter', 'flash',
33 | 'flysystem', 'flysystem_manager',
34 | 'lang', 'log', 'queue',
35 | 'redirect', 'request', 'response',
36 | 'route', 'security', 'session',
37 | 'tag', 'url', 'view',
38 |
39 | # path
40 | 'base_uri',
41 |
42 | # php
43 | 'strtotime',
44 | ];
45 |
46 | /**
47 | * Constructor.
48 | *
49 | * @param mixed|\Phalcon\Mvc\ViewBaseInterface $view
50 | * @param mixed|\Phalcon\DiInterface $di
51 | */
52 | public function __construct(ViewBaseInterface $view, DiInterface $di = null)
53 | {
54 | parent::__construct($view, $di);
55 |
56 | $debug = false;
57 |
58 | if (config()->app->debug) {
59 | $debug = true;
60 | }
61 |
62 | $this->setOptions([
63 | 'compiledSeparator' => '_',
64 | 'compiledPath' => storage_path('views').'/',
65 | 'compileAlways' => $debug,
66 | ]);
67 |
68 | foreach ($this->functions as $func) {
69 | $this->getCompiler()->addFunction($func, $func);
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/Clarity/View/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "clarity/view",
3 | "description": "",
4 | "license": "MIT",
5 | "homepage": "http://github.com/ps-clarity/view",
6 | "support": {
7 | "issues": "https://github.com/ps-clarity/view/issues",
8 | "source": "https://github.com/ps-clarity/view"
9 | },
10 | "authors": [
11 | {
12 | "name": "Daison Carino",
13 | "email": "daison12006013@gmail.com"
14 | }
15 | ],
16 | "require": {
17 | "clarity/kernel": "1.4.*",
18 | "clarity/support": "1.4.*",
19 | "jenssegers/blade": "^1.0"
20 | },
21 | "autoload": {
22 | "psr-4": {
23 | "Clarity\\View\\": ""
24 | }
25 | },
26 | "extra": {
27 | "branch-alias": {
28 | "dev-master": "1.4-dev"
29 | }
30 | },
31 | "minimum-stability": "dev"
32 | }
33 |
--------------------------------------------------------------------------------
/tests/.env.travis:
--------------------------------------------------------------------------------
1 | SERVE_HOST=0.0.0.0
2 | SERVE_PORT=8080
3 |
4 | APP_KEY=travis
5 | APP_ENV=travis
6 | APP_DEBUG=true
7 |
8 | DB_ADAPTER=mysql
9 | DB_HOST=localhost
10 | DB_PORT=3306
11 | DB_DATABASE=slayer
12 | DB_USERNAME=root
13 | DB_PASSWORD=
14 |
--------------------------------------------------------------------------------
/tests/clarity/Console/CLITest.php:
--------------------------------------------------------------------------------
1 | function ($input, $output) {
11 |
12 | # I must be able to call a CLI or any classes here
13 | CLI::process('echo "Testing CLI::handleCallback()"');
14 |
15 | $output->writeln('testing writeln with comment style');
16 | $output->writeln('testing writeln with error style');
17 |
18 | # also when returning an array or string
19 | # it should be able to handle this scripts
20 | return ['echo "Script 1: returning array in callback"'];
21 | },
22 | 'travis_ci_script_2' => 'echo "Script 2: using CLI::process()"',
23 | 'travis_ci_script_3' => [
24 | 'echo "Script 3: using CLI::bash()"',
25 | ],
26 | 'travis_ci_script_4' => CLI::ssh('root@domain.com', ['ls'], $execute = false),
27 | 'travis_ci_script_5' => function ($input, $output) {
28 | return 'echo "Script 5: returning string in callback"';
29 | },
30 | ];
31 |
32 | # a callback, returning array
33 | CLI::handleCallback($scripts['travis_ci_script_1']);
34 |
35 | # a string
36 | CLI::process($scripts['travis_ci_script_2']);
37 |
38 | # an array
39 | CLI::bash($scripts['travis_ci_script_3']);
40 |
41 | # a generated ssh script
42 | // CLI::process($scripts['travis_ci_script_4']);
43 |
44 | # a callback, returning string
45 | CLI::handleCallback($scripts['travis_ci_script_5']);
46 |
47 | # this must automatically be executed, the third
48 | # parameter is automatically assigned as true
49 | // CLI::ssh('root@domain.com', ['ls']);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/tests/clarity/Console/ServerTest.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Console;
12 |
13 | /**
14 | * The 'server' test case.
15 | */
16 | class ServerTest extends \PHPUnit_Framework_TestCase
17 | {
18 | /**
19 | * {@inheritdoc}
20 | */
21 | public function tearDown()
22 | {
23 | $compiled_file = 'storage/slayer/compiled.php';
24 |
25 | if (file_exists($compiled_file)) {
26 | di()->get('flysystem')->delete($compiled_file);
27 | }
28 | }
29 |
30 | /**
31 | * Test the 'optimize' console command.
32 | *
33 | * @return void
34 | */
35 | public function testOptimizeCommand()
36 | {
37 | CLI::bash([
38 | 'php brood optimize --force',
39 | ]);
40 |
41 | $has_file = file_exists(config()->path->storage.'slayer/compiled.php');
42 | $this->assertTrue($has_file, 'check if classes were generated and compiled');
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/tests/clarity/Providers/ResolverTest.php:
--------------------------------------------------------------------------------
1 |
7 | * @license http://www.opensource.org/licenses/mit-license.php MIT
8 | * @link http://docs.phalconslayer.com
9 | */
10 |
11 | namespace Clarity\Providers;
12 |
13 | /**
14 | * Test the resolver.
15 | */
16 | class ResolverTest extends \PHPUnit_Framework_TestCase
17 | {
18 | /**
19 | * Test for service providers.
20 | *
21 | * @return void
22 | */
23 | public function testService()
24 | {
25 | $this->assertFalse(di()->has('mail'));
26 |
27 | resolve('mail');
28 |
29 | $this->assertTrue(di()->has('mail'));
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/tests/clarity/Support/CurlTest.php:
--------------------------------------------------------------------------------
1 | getClient()->get('/auth/login');
14 |
15 | $this->assertEquals(200, $ret->getStatusCode());
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/tests/clarity/Support/Phalcon/HttpTest.php:
--------------------------------------------------------------------------------
1 | toArray();
10 |
11 | # let's change the server host and port
12 | config([
13 | 'app' => [
14 | 'base_uri' => [
15 | 'main' => env('SERVE_HOST').':'.env('SERVE_PORT'),
16 | ],
17 | ],
18 | ]);
19 |
20 | $request = request()->module('main')->get('/auth/login');
21 |
22 | $this->assertEquals(200, $request->getStatusCode());
23 |
24 | # reset
25 | config($old, false);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/tests/clarity/Support/Phalcon/MvcTest.php:
--------------------------------------------------------------------------------
1 | toArray();
14 |
15 | # since we're loading the default 'main' module
16 | # located at root/autoload.php
17 | $this->assertEquals('http://', di()->get('url')->getScheme());
18 | $this->assertEquals('slayer.app', di()->get('url')->getHost());
19 | $this->assertEquals('http://slayer.app', di()->get('url')->getFullUrl());
20 |
21 | # https check
22 | config([
23 | 'app' => [
24 | 'ssl' => [
25 | 'acme' => true,
26 | ],
27 | 'base_uri' => [
28 | 'acme' => 'acme.app',
29 | ],
30 | ],
31 | ]);
32 | $this->assertEquals('https://', di()->get('url')->getScheme('acme'));
33 | $this->assertEquals('acme.app', di()->get('url')->getHost('acme'));
34 | $this->assertEquals('https://acme.app', di()->get('url')->getFullUrl('acme'));
35 |
36 | # revert config
37 | config($old, false);
38 |
39 | # http check
40 | $this->assertEquals('http://', di()->get('url')->getScheme('main'));
41 | $this->assertEquals('slayer.app', di()->get('url')->getHost('main'));
42 | $this->assertEquals('http://slayer.app', di()->get('url')->getFullUrl('main'));
43 |
44 | # let's call the di 'route' to register these routes
45 | route()->add('/test', [
46 | 'controller' => 'Something',
47 | 'action' => 'someone',
48 | ])->setName('test');
49 |
50 | route()->add('/test/{id}', [
51 | 'controller' => 'Something',
52 | 'action' => 'someone',
53 | ])->setName('testWithId');
54 |
55 | route()->add('/test/{id}', [
56 | 'controller' => 'Something',
57 | 'action' => 'someone',
58 | ])->setName('testWithParamsAndRaw');
59 |
60 | # we need to call the url() helper to be able to call
61 | # the registered 'router'
62 | $simple_route = url()->route('test');
63 | $params_route = url()->route('testWithId', ['id' => 1]);
64 | $raw_route = url()->route('testWithParamsAndRaw', ['id' => 1], ['debug' => true]);
65 |
66 | $this->assertEquals($simple_route, 'http://slayer.app/test');
67 | $this->assertEquals($params_route, 'http://slayer.app/test/1');
68 | $this->assertEquals($raw_route, 'http://slayer.app/test/1?debug=1');
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/tests/slayer/config/AppTest.php:
--------------------------------------------------------------------------------
1 | assertContains(config('app.debug'), [
10 | true,
11 | false,
12 | ]);
13 |
14 | $this->assertContains(config()->app->debug, [
15 | true,
16 | false,
17 | ]);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------