How to collect output of a custom phing task in a phing property? - phing

Background
I started with this open ended question https://stackoverflow.com/questions/36602830/list-differences-between-two-directories-from-point-of-view-of-one-directory-by
Then tried this to solve it using phing's native utilities, but got stuck - How to return a value from a phing target?
Now I am trying to write a custom Phing task, as per https://www.phing.info/docs/guide/trunk/ch06s06.html. I tried echoing the list of files in this, with an intention to somehow collect the same in a property when the task is called from the build xml -
<addedfiles message="Hello World" outputProperty="output"/>
But I found that an outputProperty attribute is not supported in the call from the build xml file.
Any pointers on how to do this, or to the other two questions would help a lot.

Oh it is simple. We can set a property within the custom task class like this -
$this->getProject()->setNewProperty('output', "hello world");
and it can be accessed in the build xml, after the task call, like this -
<addedfiles message="Hello World" />
<echo>See ${output}</echo>

You can improve your solution doing this
private $outputProperty;
public function setOutputProperty($str)
{
$this->outputProperty = $str;
}
and then, when you catch the output
$this->getProject()->setNewProperty($this->outputProperty, "hello world");

Related

Flutter write script for to write code in project

I have a file inside my Flutter-project. A simple .dart file which looks like this:
class EnLanguage implements BaseLanguage {
#override
Map<String, String> get language => {'test': 'test'};
}
Now my goal is that I write I script which I by executing goes through all my Project-files, searches for specific Strings ( the ones with a .tr ending) and adds it to the map in the class above (key and value are the same).
I couldn't find any way to achieve this. How does a simple script looks like that can write inside my project files? Im not asking for the whole logic, I just need a start. I couldn't find anything..
Have a look at the package dcli and specifically the pack command. It does a chunk of what you need.
Not quite certain what you mean by strings ending with a .tr.
But to process each script.
var project = DartProject.self.pathToPackage;
find('*.dart', workingDirectory: project)
.forEach((script) {
read(script). forEach((line) {
If (line. contains('.tr'))
{
Extract line...
Write to generated file..
}

Not able to read from powershell argument list

I have a simple dotnet application which i want to execute from powershell. but while i am passing the arguments in powershell my dotnet application is not able to catch those value.
I am not sure where the error is. is it in dotnet side or in powershell.
dotnet winform
private void Form1_load(object sender, EventArgs e)
{
string[] passedArgs = Environment.GetCommandLineArgs();
foreach(string s in passedArgs)
{
textBox1.Text = s.ToString();
}
}
powershell script
PS C:\Users\528741> Start-Process 'D:\MVC\PowershellTest\PowershellTest\bin\Debug\PowershellTest.exe' -ArgumentList '/hello'
Thanks,
Rosalini
It's difficult to tell without seeing the rest of the application what might be going wrong, as what you've shown us is pretty straightforward. Things to try:
textbox1.Text = "Does a string literal work?";
If the textbox doesn't display your string literal, the issue is in your C# or in the design of your winforms application. Maybe textbox1 isn't visible anymore and you have some other textbox object displayed? Maybe the Form1_load() method isn't being called when you think it is. Did a name get changed somewhere? If that's the case I would suggest recreating the form and pasting your code for the Form1_load() method into there and try again.
If it does display as expected, then I would suspect something with Powershell. Have you tried without Start-Process? Like:
& "D:\MVC\PowershellTest\PowershellTest\bin\Debug\PowershellTest.exe" "I'm argument 1" "This is argument 2" "3rd argument here!"
Also, as your code looks simple enough, are you sure this is the correct path to your executable? Have you rebuilt your solution after making your changes to the code? Simple oversights like this are often the issue.

How can i call the coffee script function on body load

I am using the app.coffee coffee script file to create some animations on the framerjs prototyping tool. what i want to achieve is that i have defined a function and i want to call that function on body load. how can i do that in coffeescript?
Code:
changeNumbers = ->
sketch.More_Details_Text.visible = false
sketch.Less_Details_Text.visible = true
expandanimation1.start()
You just call the function in your app.coffee
changeNumbers()
This is executed whenever you open or reload your prototype.
This answer might be too simple but maybe you can explain your problem more if that doesn't help. Are you working in Framer Studio?

neo4jphp: Cannot instantiate abstract class Everyman\Neo4j\Transport

maybe a simple question but for me as starter with Neo4j a hurdle. I installed the neo4jphp with composer in the same directory as my application. Vendor-Subfolder has been created and the everyman/neo4j folder below is available. For a first test I used this code snippet from the examples:
spl_autoload_register(function ($className) {
$libPath = 'vendor\\';
$classFile = $className.'.php';
$classPath = $libPath.$classFile;
if (file_exists($classPath)) {
require($classPath);
}
});
require('vendor/autoload.php');
use everyman\Neo4j\Client,
everyman\Neo4j\Transport;
$client = new Client(new Transport('localhost', 7474));
print_r($client->getServerInfo());
I always stumple upon the error
Fatal error: Cannot instantiate abstract class Everyman\Neo4j\Transport
Googling brought me to a comment from Josh Adell stating
You can't instantiate Everyman\Neo4j\Transport, since it is an abstract class. You must instantiate Everyman\Neo4j\Transport\Curl or Everyman\Neo4j\Transport\Stream depending on your needs
So I thought I just need to alter the use-statements to
use everyman\Neo4j\Client,
everyman\Neo4j\Transport\Curl;
but this doesnt work, debugging shows, that the autoloader only get "Transport.php" instead of "everyman\Neo4j\Transport\Curl.php". For "Client.php" its still working ("vendor\everyman\Neo4j\Client.php") so I am guessing that the use-statement is wrong or the code is not able to handle an additional subfolder-structure.
Using
require('phar://neo4jphp.phar');
works fine but I read that this is deprecated and should be replaced by composer / autoload.
Anyone has a hint what to change or had the same problem?
Thanks for your time,
Balael
Curl is the default transport. You only need to instantiate your own Transport object if you want to use Stream instead of Curl. If you really want to instantiate your own Curl Transport, the easiest change to your existing code is to modify the use statement to be:
use everyman\Neo4j\Client,
everyman\Neo4j\Transport\Curl as Transport;
Also, you don't need to register your own autoload function if you are using the Composer package. vendor/autoload.php does that for you.
Thanks Josh, I was trying but it seems I still stuck somewhere. I am fine with using the default CURL - so I shrinked the code down to
require('vendor/autoload.php');
use everyman\Neo4j\Client;
$client = new Everyman\Neo4j\Client('localhost', 7474);
print_r($client->getServerInfo());`
The folder structure is main (here are the files and the composer.json with the content
{
"require": {
"everyman/Neo4j": "dev-master"
}
}
and in the subfolder "vendor" we have the "autoload.php" and the subfolder everyman with the related content. When I run the file I come out with
Fatal error: Class 'Everyman\Neo4j\Client' not found
which does not happen when I have the autoloadfunction. I guess I made a mistake somewehere - can you give me a hint?
Thanks a lot, B
Hmmm... I was just trying around and it seems the Transport CLASS is not needed in the use-statement and the class instantiation. This seems to work:
require('vendor/autoload.php');
use everyman\Neo4j\Client;
$client = new Client();
print_r($client->getServerInfo());
also valid for having a dedicated server/port:
$client = new Everyman\Neo4j\Client('localhost', 7474);
If you have more input I would be happy to learn more - thanks, all input & thoughts are very appreciated.
Balael

How to get values from controller

I am trying to print hello world.
For that i created class and return function in models folder, and the returning value is "hello world".
In controller, i am getting the values from module like this:
$value = new getValue();
$this->view->index = $value->hello_world();
I don't know how to get the values from controllers and print into views php folder.
In fac, you put "Hello world" string into the variable "index" of the controller's view when your are doing this $this->view->index = $value->hello_world();.
So, if your $value->hello_world(); function correctly return an "Hello world" string, for print it into the controller's view, you just have to do add this php code echo $this->index; into your view file.
I really think you should read a tutorial first of all. It can be quite hard to try to figure out how Zend Framework works just by starting to code right away.
The Quick Start guide suggested by #palmplam should be fine.
In addition, I found the Rob Allen's tutorial really useful when I started using Zend Framework. It contains plenty of sample code.