I have the following data structure in my params.pp file at /etc/puppet/modules/appserver/manifests
class appserver::params {
$servers = {
appserver-mgr => { axis2 => {subDomain => 'mgt',},
carbon => {subDomain => 'mgt',},
serverOptions => '-Dsetup', },
appserver-wkr => { axis2 => {subDomain => 'worker',},
carbon => {subDomain => 'worker',},
serverOptions => '-DworkerNode=true', },
}
$serversDefaults = {
clustering => 'true',
}
}
In my template file (axis2.xml.erb at /etc/puppet/modules/appserver/templates). I have to fill the following field.
<property name="subDomain" value="<%= #subDomain %>"/>
How can I fill this subDomain value using the above data structure in params.pp file?
The hash translates to Ruby quite literally.
<property name="subDomain" value="<%= #servers['appserver-mgr']['carbon']['subDomain'] %>"/>
This assumes that $servers has the value of appserver::params::server in the scope of the template expansion.
Related
I'm new to Livewire and I faced this problem Call to a member function store() on null I don't know how to make the store() function not work when I don't send a file! graduation_certificate it is nullable.
Database file
public function up()
{
Schema::create('user_trainees', function(Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->integer('region_id')->unsigned();
$table->integer('city_id')->unsigned();
$table->integer('university_id')->unsigned();
$table->integer('department_id')->unsigned();
$table->string('major', 150);
$table->bigInteger('student_number')->nullable();
$table->float('gpa');
$table->enum('gpa_type', array('4', '5'));
$table->enum('training_date', array('firstsemester', 'secondsemester', 'thirdsemester', 'summersemester'))->nullable();
$table->integer('training_hours')->nullable();
$table->integer('graduation_year')->nullable();
$table->enum('academic_degree', array('bachelor', 'diploma'));
$table->string('graduation_certificate', 200)->nullable();
$table->string('academic_transaction', 200);
$table->string('cv', 200);
$table->tinyInteger('is_graduate');
$table->timestamps();
$table->softDeletes();
});
}
blade file
<x-form.label label="وثيقة التخرج" name="graduation_certificate" />
<div class="flex">
<input type="file" wire:model="graduation_certificate" name="graduation_certificate"
id="graduation_certificate"
class="px-8 py-12 border-2 border-dashed rounded-md dark:border-gray-700 dark:text-gray-400 dark:bg-gray-800">
</div>
livewire class
public function submit()
{
$user_uni = User::create([
'name' => "{$this->firstName} {$this->lastName}",
'type_id' => $this->userType,
'email' => $this->email,
'password' => bcrypt($this->password),
'gender' => $this->gender,
'mobile' => $this->mobile,
'is_active' => 1,
]);
UserTrainee::create([
'user_id' => $user_uni->id,
'region_id' => $this->region,
'city_id' => $this->city,
'university_id' => $this->university,
'department_id' => $this->department,
'major' => $this->major,
'student_number' => $this->studentNumber,
'gpa' => $this->gpa,
'gpa_type' => $this->gpa_type,
'training_date' => $this->training_date,
'training_hours' => $this->trainingHours,
'graduation_year' => $this->graduation_year,
'academic_degree' => $this->academic_degree,
'graduation_certificate' => $this->graduation_certificate->store('files', 'public'),
'academic_transaction' => $this->academic_transaction->store('files', 'public'),
'cv' => $this->cv->store('files', 'public'),
'is_graduate' => $this->traineeType,
]);
}
You don't conditionally store the files, meaning that even if you haven't uploaded something (meaning its NULL), you attempt to store it. Just wrap some conditions around it,
// ...
'graduation_certificate' => $this->graduation_certificate ? $this->graduation_certificate->store('files', 'public') : null,
'academic_transaction' => $this->academic_transaction ? $this->academic_transaction->store('files', 'public') : null,
'cv' => $this->cv ? $this->cv->store('files', 'public') : null,
// ...
you have to make variable of cv like you made for graduation_certificate, cv is getting NULL that's why you are facing this error
I have below table structure.
Mandator table
class MandatorTable extends Table
{
public function initialize(array $config)
{
$this->table('mandators');
$this->belongsToMany('Seminar', [
'foreignKey' => 'mandator_id',
'targetForeignKey' => 'seminar_id',
'joinTable' => 'mandators_seminars'
]);
}
}
Semiar table
class SeminarTable extends Table
{
public function initialize(array $config)
{
$this->table('seminars');
$this->belongsToMany('Mandator', [
'foreignKey' => 'seminar_id',
'targetForeignKey' => 'mandator_id',
'joinTable' => 'mandators_seminars'
]);
}
}
both table are belong to 'mandators_seminars' table
mandator_id, seminar_id
When I save data it's save in seminar table but not in 'mandators_seminars' table
Query
$seminartable = $this->Seminar->newEntity();
$this->request->data['mandator'][0] = 1;
$seminardata = $this->Seminar->patchEntity($seminartable, $this->request->data);
$this->Seminar->save($seminardata)
Request data
Array
(
[bookable] => test
[released] => aaa
[linkable] => bb
[name] => ccc
[internalnote] => ddd
[abstract] => ttt
[description] => ddd
[Category] => 14
[mandator] => Array
(
[0] => 1
)
[mandator_owner_id] => 1
)
Look you have two table Mandator and Similar as singular , but your connecting table is plural. Firstly check this. If there is still a problem check this CakePHP Through Association
As you can see your association should be like this:
$this->belongsToMany('Mandator', [
'foreignKey' => 'seminar_id',
'targetForeignKey' => 'mandator_id',
'through' => 'PluginName.MandatorsSeminars'
'joinTable' => 'mandators_seminars',
'className' => 'PluginName.Mandator'
]);
And one more tip: table should be called as plural.
I make UnitTesting for my application.
I have a save saveArticleIds() Method and I wrote a testing for it -> testSaveArticelIds(). I have an dataProvider articelIdsArray() whith a multiple array. The function need that array exact like this.
/**
*
* #dataProvider articleIdsArray
*
*/
public function testSavearticleIds($articleIds) {
$articleIdObjekt = new ArticleIdHandler();
$result = $articleIdObjekt->saveArticleIds($articleIds,false);
$this->assertTrue($result);
}
public function articleIdsArray() {
return array(
array(
10552 => 10552,
14314 => 14314,
21034 => 21034,
22739 => 22739,
34568 => 34568,
34572 => 34572,
35401 => 35401,
38292 => 38292,
55141 => 55141,
161764 => 161764,
181589 => 181589
)
);
}
When I run my test, I get this Error:
There was 1 error: 1) My\Bundle\ArticleBundle\Tests\Article\ArticleIdHandlerTest::testSaveArticleIds
with data set #0 (10552, 14314, 21034, 22739, 34568, 34572, 35401, 38292, 55141, 161764, 181589)
Invalid argument supplied for foreach()
Why does it show the array like I have no keys in the array? I need the array exact like in my dataProvider! Any idea?? THANKS A LOT FOR YOU HELP!!!
maybe try this:
public function articleIdsArray()
{
return
array(
array(
array(
10552 => 10552,
14314 => 14314,
21034 => 21034,
22739 => 22739,
34568 => 34568,
34572 => 34572,
35401 => 35401,
38292 => 38292,
55141 => 55141,
161764 => 161764,
181589 => 181589
)
)
);
}
The reason is that the first level of the array nesting is the set of data provided for each round of tests, the second level represents the arguments provided to testSavearticleIds, in the same order as in the parameter list of the function (in your example there is only one argument), the last level is just the test array itself.
Hope this helps...
Try this :
/**
* #dataProvider articleIdsArray
*/
public function testSavearticleIds($articleIds)
{
$articleIdObjekt = new ArticleIdHandler();
$result = $articleIdObjekt->saveArticleIds($articleIds,false);
$this->assertTrue($result);
}
public function articleIdsArray()
{
return array(
'scenario_one' => 10552,
'scenario_two' => 14314,
...,
);
}
You doesn't need to use #dataProvider in your example.
Define your method like this
public function getArticleIdsArray() {
return array(
10552 => 10552,
14314 => 14314,
21034 => 21034,
22739 => 22739,
34568 => 34568,
34572 => 34572,
35401 => 35401,
38292 => 38292,
55141 => 55141,
161764 => 161764,
181589 => 181589
);
}
and use it in your test
public function testSavearticleIds($articleIds) {
$articleIdObjekt = new ArticleIdHandler();
$result = $articleIdObjekt->saveArticleIds($this->getArticleIdsArray(),false);
$this->assertTrue($result);
}
I had a problem on how to apply row Template data binding into it. I not sure what is the syntax to do so. I am using server binding mode. Below is my code
#(Html.Kendo().Grid((IEnumerable<IcmsViewModel.LookupView>)ViewData["LookupView"]) // Bind the grid to the Model property of the view
.Name("Grid")
.CellAction(cell =>
{
if (cell.DataItem.Active == false)
{
cell.HtmlAttributes["style"] = "background-color: red";
}
}
)
.Columns(columns =>
{
columns.Bound(p => p.LookupValue).ClientTemplate(" ").Title("Short Name").Width(300);
columns.Bound(p => p.Description).Width(300);
columns.Bound(p => p.Active).Width(300);
columns.Command(command => { command.Edit(); command.Destroy(); });
})
**.RowTemplate(rows =>
"<tr><td>Testing</td>" +
"<td colspan=\"2\"><input type=\"button\" name=\"ClickMe\" value=\"ClickMe\" onclick=\"javascript:window.open(('/Test/ViewTest'), 'ViewTest', 'height=' + (window.screen.height - 100) + ',width=200,left=' + (window.screen.width - 250) + ',top=10,status=no,toolbar=no,resizable=yes,scrollbars=yes');\"/></td>" +
"<td>Name</td></tr>"
)**
.ToolBar(commands => commands.Create())
.Groupable()
.Pageable()
.Sortable()
//.Filterable()
.Scrollable(x => x.Height(600))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.DataSource(dataSource => dataSource
.Server()
.Model(model => { model.Id(p => p.Id); model.Field(p => p.Id).Editable(false); })
.Create(create => create.Action("CreateLookup", "Icms"))
.Read(read => read.Action("Lookup", "Icms"))
.Update(update => update.Action("UpdateLookup", "Icms"))
.Destroy(destroy => destroy.Action("Destroy", "Sample"))
)
)
Currently I hard code the value in the row template, how can I bind it with the data in database, if i want to apply the row template.
Example
.RowTemplate(rows =>
"p.LookupValue" +
"" +
"p.Description"
)
Please help me on this as I am new to kendo UI. Thanks a lot.
Why don't you use Template on the column definition :
.Columns(columns =>
{
columns.Bound(p => p.LookupValue)
.Template(#<text>#item.LookupValue #item.Description</text>).Title("Short Name").Width(300);
columns.Bound(p => p.Active).Width(300);
columns.Command(command => { command.Edit(); command.Destroy(); });
})
I would like to return an array of string in my web services
I've tryed :
<?php
require_once('nusoap/nusoap.php');
$server = new soap_server();
$server->configureWSDL('NewsService', 'urn:NewsService');
$server->register('GetAllNews',
array(),
array('return' => 'xsd:string[]'),
'urn:NewsService',
'urn:NewsService#GetAllNews',
'rpc',
'literal',
''
);
// Define the method as a PHP function
function GetAllNews()
{
$stack = array("orange", "banana");
array_push($stack, "apple", "raspberry");
return $stack;
}
but it doesn't work.
What is the correct syntax for that ?
Thanks in advance for any help
You can't return an array like this. To return an array, you have to define a complex type.
I'll provide u an example...
The server program service.php:
<?php
// Pull in the NuSOAP code
require_once('lib/nusoap.php');
// Create the server instance
$server = new soap_server();
// Initialize WSDL support
$server->configureWSDL('RM', 'urn:RM');
//Define complex type
$server->wsdl->addComplexType(
'User',
'complexType',
'struct',
'all',
'',
array(
'Id' => array('name' => 'Id', 'type' => 'xsd:int'),
'Name' => array('name' => 'Name', 'type' => 'xsd:string'),
'Email' => array('name' => 'Email', 'type' => 'xsd:string'),
'Description' => array('name' => 'Description', 'type' => 'xsd:string')
)
);
// Register the method
$server->register('GetUser', // method name
array('UserName'=> 'xsd:string'), // input parameters
array('User' => 'tns:User'), // output parameters
'urn:RM', // namespace
'urn:RM#GetUser', // soapaction
'rpc', // style
'encoded', // use
'Get User Details' // documentation
);
function GetUser($UserName) {
return array('Id' => 1,
'Name' => $UserName,
'Email' =>'test#a.com',
'Description' =>'My desc'
);
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
And the client program client.php:
<?php
// Pull in the NuSOAP code
require_once('lib/nusoap.php');
// Create the client instance
$client = new soapclient('http://localhost/Service/service.php');
// Call the SOAP method
$result = $client->call('GetUser', array('UserName' => 'Jim'));
// Display the result
print_r($result);
?>