bazzline / php_propel_behavior_entity_instantiator Goto Github PK
View Code? Open in Web Editor NEWThis free as in freedom behavior that easy up entity instantiation for propel
License: GNU Lesser General Public License v3.0
This free as in freedom behavior that easy up entity instantiation for propel
License: GNU Lesser General Public License v3.0
see subject
This idea was a result of trying to fix issue/3.
It turns out that this is a different feature and should be created as that.
Use the configured database name within the schema.xml as default.
//thats how we could get it from probel
$this->getDatabase()->getName().
wrong
/**
* @return PDO
*/
public function getConnection()
{
return Propel::getConnection();
}
right
/**
* @return \PDO
*/
public function getConnection()
{
return \Propel::getConnection();
}
When a class is generated, the method "getConnection" looks like the following.
/**
* @param null|string $name - The data source name that is used to look up the DSN from the runtime configuration file.
* @param string $mode The connection mode (this applies to replication systems).
* @return PDO
*/
public function getConnection($name = null, $mode = Propel::CONNECTION_WRITE)
{
return Propel::getConnection($name, $mode);
}
It can happen that you are using multiple databases resulting in multiple generated classes.
To still be able to get the right connection without passing around the name, it would be good to configure the default name. If the default name is configured, the generated method could look like that.
/**
* @param null|string $name - The data source name that is used to look up the DSN from the runtime configuration file.
* @param string $mode The connection mode (this applies to replication systems).
* @return PDO
*/
public function getConnection($name = null, $mode = Propel::CONNECTION_WRITE)
{
if (is_null($name)) {
$name = 'my_configured_default_value';
}
return Propel::getConnection($name, $mode);
}
The same could be done for the value "$mode".
Instead of
use Foo\Bar\Baz;
class FooLocator
{
public function createBaz()
{
return Baz::create();
}
}
it would be nice to generate something like this:
class FooLocator
{
public function createBaz()
{
return \Foo\Bar\Baz::create();
}
}
The reason is an available php bug when running php in cli mode with opcache enabled that is throwing fatal errors for all situations where a classname conflict can happen.
The bug can be triggered using this code snippets.
What about adding another configuration value like:
<paramater name="entity_instantiator_use_fully_qualified_name" value="true|false" />
If it is set to true, all the code has to do is if the classes are in the same namespace like the generator. If not, we can use the fully qualified name.
@tworzenieweb is this package still needed?
Else I would put it in archive mode.
As title, it seems that the Travis CI has been slow and unstable. And it's the third party service.
Since the GitHub Action has been released, I think it's time to migrate the Travis CI to GitHub Action.
Once this issue is accepted by @stevleibelt, I will be happy to work on this :).
When I create a file, I get something like thins in the comments.
/**
* Class <file name>
*
* @author Net\Bazzline\Propel\Behavior\EntityInstantiatorNet\Bazzline\Propel\Behavior\EntityInstantiator\FileContentGenerator
* @since 2015-11-24
* @see http://www.bazzline.net
*/
I don't think that this is expected ;-).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.