Skip to content

Commit

Permalink
First official version
Browse files Browse the repository at this point in the history
  • Loading branch information
iquito committed Apr 23, 2019
0 parents commit e3ff963
Show file tree
Hide file tree
Showing 11 changed files with 507 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/tests export-ignore
/examples export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpunit.xml export-ignore
/phpcs.xml export-ignore
/captainhook.json export-ignore
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/.idea
/composer.lock
/vendor
/.phpunit*
/tests/_output
/tests/_reports
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Andreas Leathley

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

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

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Squirrel Entities Integration for Symfony
=========================================

Integration of [squirrelphp/entities](https://github.com/squirrelphp/entities) into Symfony through bundle configuration, also needs [squirrelphp/queries-bundle](https://github.com/squirrelphp/queries-bundle).

nstallation
------------

```
composer require squirrelphp/entities-bundle
```

Configuration
-------------

Enable the bundle in your AppKernel by adding `Squirrel\EntitiesBundle\SquirrelEntitiesBundle` to the list of bundles.

Configure the directories where the bundle will look for repositories like this in Symfony / YAML:

squirrel_entities:
directories:
- '%kernel.project_dir%/src'
- '%kernel.project_dir%/possibleOtherDirectory'
It will go through these directories recusively, finding all entities and possible repositories and creating services for the repositories.

Look at `Squirrel\EntitiesBundle\DependencyInjection\ContainerExtension` to get more details about how it works, and check out the `squirrel_repositories_generate` bin command in [squirrelphp/entities](https://github.com/squirrelphp/entities) to generate repositories from entities which are then autoloaded by this bundle.

More documentation will follow!
60 changes: 60 additions & 0 deletions captainhook.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"commit-msg": {
"enabled": true,
"actions": [
{
"action": "\\CaptainHook\\App\\Hook\\Message\\Action\\Beams",
"options": {
"subjectLength": 50,
"bodyLineLength": 72
},
"conditions": []
}
]
},
"pre-push": {
"enabled": false,
"actions": []
},
"pre-commit": {
"enabled": true,
"actions": [
{
"action": "\\CaptainHook\\App\\Hook\\PHP\\Action\\Linting",
"options": [],
"conditions": []
},
{
"action": "vendor/bin/phpunit",
"options": [],
"conditions": []
},
{
"action": "vendor/bin/phpstan analyse src --level=7",
"options": [],
"conditions": []
},
{
"action": "vendor/bin/phpcs --standard=psr2 --extensions=php src tests",
"options": [],
"conditions": []
}
]
},
"prepare-commit-msg": {
"enabled": false,
"actions": []
},
"post-commit": {
"enabled": false,
"actions": []
},
"post-merge": {
"enabled": false,
"actions": []
},
"post-checkout": {
"enabled": false,
"actions": []
}
}
60 changes: 60 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "squirrelphp/entities-bundle",
"type": "library",
"description": "Symfony integration of squirrelphp/entities - automatic integration of generated repositories for existing entities.",
"keywords": [
"php",
"mysql",
"pgsql",
"sqlite",
"database",
"abstraction",
"entities",
"repositories",
"symfony",
"bundle"
],
"homepage": "https://github.com/squirrelphp/entities-bundle",
"license": "MIT",
"authors": [
{
"name": "Andreas Leathley",
"email": "andreas.leathley@panaxis.ch"
}
],
"require": {
"php": "^7.2",
"symfony/dependency-injection": "^4.0",
"symfony/http-kernel": "^4.0",
"symfony/finder": "^4.0",
"symfony/config": "^4.0",
"squirrelphp/queries-bundle": "^0.5",
"squirrelphp/entities": "^0.2"
},
"require-dev": {
"mockery/mockery": "^1.0",
"phpstan/phpstan": "^0.11.5",
"phpunit/phpunit": "^8.0",
"squizlabs/php_codesniffer": "^3.0",
"captainhook/plugin-composer": "^4.0"
},
"config": {
"sort-packages": true
},
"autoload": {
"psr-4": {
"Squirrel\\EntitiesBundle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Squirrel\\EntitiesBundle\\Tests\\": "tests/"
}
},
"scripts": {
"phpstan": "vendor/bin/phpstan analyse src --level=7",
"phpunit": "vendor/bin/phpunit --colors=always",
"phpcs": "vendor/bin/phpcs --standard=psr2 --extensions=php src tests",
"codecoverage": "vendor/bin/phpunit --coverage-html tests/_reports"
}
}
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
parameters:
excludes_analyse:
- src/DependencyInjection/Configuration.php
21 changes: 21 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.3/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="Unit Tests">
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>
</phpunit>
55 changes: 55 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace Squirrel\EntitiesBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

class Configuration implements ConfigurationInterface
{
private $alias;

public function __construct(string $alias)
{
$this->alias = $alias;
}

/**
* @inheritdoc
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root($this->alias);

/*
* The only configuration options are:
*
* - directories (there are no default directories)
* - table_names (overwriting annotated table names)
* - connection_names (overwriting annotated connection names)
*/
$rootNode
->fixXmlConfig('directory', 'directories')
->fixXmlConfig('table_name', 'table_names')
->fixXmlConfig('connection_name', 'connection_names')
->children()
->arrayNode('directories')
->prototype('scalar')
->end()
->end()
->arrayNode('table_names')
->useAttributeAsKey('class')
->prototype('scalar')
->end()
->end()
->arrayNode('connection_names')
->useAttributeAsKey('class')
->prototype('scalar')
->end()
->end()
->end();

return $treeBuilder;
}
}
Loading

0 comments on commit e3ff963

Please sign in to comment.